diff options
author | smccammon@mozilla.com <smccammon@mozilla.com@4eb1ac78-321c-0410-a911-ec516a8615a5> | 2009-08-21 03:23:09 (GMT) |
---|---|---|
committer | smccammon@mozilla.com <smccammon@mozilla.com@4eb1ac78-321c-0410-a911-ec516a8615a5> | 2009-08-21 03:23:09 (GMT) |
commit | cb1174a6d2ecdbbcc3a4454102060c20d893b997 (patch) | |
tree | e44d6a39ae6a4cf274852572c12bfe498eb254d8 /bin/maintenance.php | |
parent | c0b97325846ae0a144a39b954ac3c6d2b10e0924 (diff) |
Bug 506157, Collection stats dashboard, r=clouserw
git-svn-id: http://svn.mozilla.org/addons/trunk@49669 4eb1ac78-321c-0410-a911-ec516a8615a5
Diffstat (limited to 'bin/maintenance.php')
-rwxr-xr-x | bin/maintenance.php | 41 |
1 files changed, 41 insertions, 0 deletions
diff --git a/bin/maintenance.php b/bin/maintenance.php index 63f82c6..57f460b 100755 --- a/bin/maintenance.php +++ b/bin/maintenance.php @@ -691,6 +691,47 @@ switch ($action) { /** + * Daily collection stats + */ + case 'collection_stats': + echo "Starting collection stats update...\n"; + + $affected_rows = 0; + $date = date('Y-m-d'); + + $collection_stats = array( + 'new_subscribers' => " + SELECT '{$date}', 'new_subscribers', collection_id, COUNT(*) + FROM collection_subscriptions + WHERE DATE(created) = '{$date}' + GROUP BY collection_id", + + 'new_votes_up' => " + SELECT '{$date}', 'new_votes_up', collection_id, COUNT(*) + FROM collections_votes + WHERE DATE(created) = '{$date}' AND vote = 1 + GROUP BY collection_id", + + 'new_votes_down' => " + SELECT '{$date}', 'new_votes_down', collection_id, COUNT(*) + FROM collections_votes + WHERE DATE(created) = '{$date}' AND vote = -1 + GROUP BY collection_id", + ); + + foreach ($collection_stats as $stat => $query) { + echo "Updating {$stat}...\n"; + + $db->write("REPLACE INTO stats_collections (`date`, `name`, `collection_id`, `count`) {$query}"); + + $affected_rows += mysql_affected_rows(); + } + + break; + + + + /** * Collection weekly and monthly subscriber counts */ case 'collection_subscribers': |