]> git.mxchange.org Git - quix0rs-gnu-social.git/commitdiff
cache notice and user counts in sitemap index
authorEvan Prodromou <evan@status.net>
Mon, 12 Apr 2010 16:13:48 +0000 (12:13 -0400)
committerEvan Prodromou <evan@status.net>
Tue, 1 Jun 2010 20:52:27 +0000 (13:52 -0700)
plugins/Sitemap/sitemapindex.php

index 7942bc3bd0de1e42119d0bfc71a8d88fa855c205..2055dd7f067bebcae16ecf905880d7efc489c8ef 100644 (file)
@@ -101,20 +101,25 @@ class SitemapindexAction extends Action
 
     function getUserCounts()
     {
-        // XXX: cachemeplease
+        $userCounts = User::cacheGet('sitemap:user:counts');
 
-        $user = new User();
+        if ($userCounts === false) {
 
-        $user->selectAdd();
-        $user->selectAdd('date(created) as regdate, count(*) as regcount');
-        $user->groupBy('regdate');
+            $user = new User();
 
-        $user->find();
+            $user->selectAdd();
+            $user->selectAdd('date(created) as regdate, count(*) as regcount');
+            $user->groupBy('regdate');
 
-        $userCounts = array();
+            $user->find();
 
-        while ($user->fetch()) {
-            $userCounts[$user->regdate] = $user->regcount;
+            $userCounts = array();
+
+            while ($user->fetch()) {
+                $userCounts[$user->regdate] = $user->regcount;
+            }
+
+            User::cacheSet('sitemap:user:counts', $userCounts);
         }
 
         return $userCounts;
@@ -122,20 +127,25 @@ class SitemapindexAction extends Action
 
     function getNoticeCounts()
     {
-        // XXX: cachemeplease
+        $noticeCounts = Notice::cacheGet('sitemap:notice:counts');
 
-        $notice = new Notice();
+        if ($noticeCounts === false) {
 
-        $notice->selectAdd();
-        $notice->selectAdd('date(created) as postdate, count(*) as postcount');
-        $notice->groupBy('postdate');
+            $notice = new Notice();
 
-        $notice->find();
+            $notice->selectAdd();
+            $notice->selectAdd('date(created) as postdate, count(*) as postcount');
+            $notice->groupBy('postdate');
 
-        $noticeCounts = array();
+            $notice->find();
+
+            $noticeCounts = array();
+
+            while ($notice->fetch()) {
+                $noticeCounts[$notice->postdate] = $notice->postcount;
+            }
 
-        while ($notice->fetch()) {
-            $noticeCounts[$notice->postdate] = $notice->postcount;
+            Notice::cacheSet('sitemap:notice:counts', $noticeCounts);
         }
 
         return $noticeCounts;