]> git.mxchange.org Git - quix0rs-gnu-social.git/commitdiff
reduce the number of queries required to get a notice's groups
authorEvan Prodromou <evan@status.net>
Mon, 1 Aug 2011 20:59:43 +0000 (16:59 -0400)
committerEvan Prodromou <evan@status.net>
Mon, 1 Aug 2011 20:59:43 +0000 (16:59 -0400)
classes/Notice.php

index 6540490b9a7aea33f3b30e6b4e2f1501f35ae80a..d577408feff2206a444a4320568957ee89e27f42 100644 (file)
@@ -1438,25 +1438,14 @@ class Notice extends Memcached_DataObject
 
             $gi->notice_id = $this->id;
 
-            if ($gi->find()) {
-                while ($gi->fetch()) {
-                    $ids[] = $gi->group_id;
-                }
-            }
-
+            $ids = $gi->fetchAll('group_id');
+            
             self::cacheSet($keypart, implode(',', $ids));
         }
 
-        $groups = array();
-
-        foreach ($ids as $id) {
-            $group = User_group::staticGet('id', $id);
-            if ($group) {
-                $groups[] = $group;
-            }
-        }
-
-        return $groups;
+               $groups = User_group::multiGet('id', $ids);
+               
+               return $groups->fetchAll();
     }
 
     /**