summaryrefslogtreecommitdiff
path: root/plugins
diff options
context:
space:
mode:
authorEvan Prodromou <evan@status.net>2010-04-12 12:13:48 -0400
committerEvan Prodromou <evan@status.net>2010-06-01 13:52:27 -0700
commite363b724b96d0509e56edabcb7fb199698e158b7 (patch)
treeb74e19750e71d9c97e55661dd7e450b70ce8bfe1 /plugins
parent5ff9c0242b2ad1df22af5630a7ebfdcce8177212 (diff)
cache notice and user counts in sitemap index
Diffstat (limited to 'plugins')
-rw-r--r--plugins/Sitemap/sitemapindex.php46
1 files changed, 28 insertions, 18 deletions
diff --git a/plugins/Sitemap/sitemapindex.php b/plugins/Sitemap/sitemapindex.php
index 7942bc3bd..2055dd7f0 100644
--- a/plugins/Sitemap/sitemapindex.php
+++ b/plugins/Sitemap/sitemapindex.php
@@ -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;