We are no longer offering accounts on this server. Consider https://gitlab.freedesktop.org/ as a place to host projects.

Commit e363b724 authored by Evan Prodromou's avatar Evan Prodromou

cache notice and user counts in sitemap index

parent 5ff9c024
...@@ -101,20 +101,25 @@ class SitemapindexAction extends Action ...@@ -101,20 +101,25 @@ class SitemapindexAction extends Action
function getUserCounts() function getUserCounts()
{ {
// XXX: cachemeplease $userCounts = User::cacheGet('sitemap:user:counts');
$user = new User(); if ($userCounts === false) {
$user->selectAdd(); $user = new User();
$user->selectAdd('date(created) as regdate, count(*) as regcount');
$user->groupBy('regdate');
$user->find(); $user->selectAdd();
$user->selectAdd('date(created) as regdate, count(*) as regcount');
$user->groupBy('regdate');
$userCounts = array(); $user->find();
while ($user->fetch()) { $userCounts = array();
$userCounts[$user->regdate] = $user->regcount;
while ($user->fetch()) {
$userCounts[$user->regdate] = $user->regcount;
}
User::cacheSet('sitemap:user:counts', $userCounts);
} }
return $userCounts; return $userCounts;
...@@ -122,20 +127,25 @@ class SitemapindexAction extends Action ...@@ -122,20 +127,25 @@ class SitemapindexAction extends Action
function getNoticeCounts() function getNoticeCounts()
{ {
// XXX: cachemeplease $noticeCounts = Notice::cacheGet('sitemap:notice:counts');
$notice = new Notice(); if ($noticeCounts === false) {
$notice->selectAdd(); $notice = new Notice();
$notice->selectAdd('date(created) as postdate, count(*) as postcount');
$notice->groupBy('postdate');
$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()) { Notice::cacheSet('sitemap:notice:counts', $noticeCounts);
$noticeCounts[$notice->postdate] = $notice->postcount;
} }
return $noticeCounts; return $noticeCounts;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment