Campustream 1.0
A social network MQP for WPI
application/controllers/admin/stats.php
Go to the documentation of this file.
00001 <?
00007 class Stats_Controller extends Controller {
00008         public $template = 'template/main';
00009         public $enable_session = true;
00010         
00011         public function index($args) {
00012                 $r = RedisManager::connection();
00013                 
00014                 // Get stats by method
00015                 $method_len = $r->llen('stats:by_method');
00016                 $method_stats = $r->lrange('stats:by_method', 0, $method_len);
00017 
00018                 $stats_by_method = array();
00019                 foreach($method_stats as $method) {
00020                         $method = unserialize($method);
00021                         
00022                         $key = "stats:{$method['controller']}:{$method['method']}:{$method['format']}:page_views";
00023                         $stats_by_method[$method['controller']][$method['method']][$method['format']] = $r->get($key);
00024                 }
00025                 
00026                 ksort($stats_by_method);
00027                 
00028                 // Total page views for site
00029                 $total_views = $r->get('stats:total_views');
00030                 
00031                 $view = new View('admin/stats');
00032                 $view->total_views = $total_views;
00033                 $view->stats_by_method = $stats_by_method;
00034                 
00035                 $this->template->content = $view->render();
00036                 echo $this->template->render();
00037         }
00038 }