First version of the new statistics page

- shows a heatmap of user activity based on the logs
- can show it for all users or for users of a specific org
pull/217/head
iglocska 2014-01-09 10:04:53 +01:00
parent f8424d484b
commit ba4e136ace
3 changed files with 43 additions and 0 deletions

View File

@ -221,4 +221,27 @@ class LogsController extends AppController {
$this->render('admin_index');
}
}
public function returnDates($startDate, $endDate, $org = 'all') {
$startDate = date('Y-m-d H:i:s', $startDate);
$endDate = date('Y-m-d H:i:s', $endDate);
$conditions = array();
$conditions = array('created <' => $endDate, 'created >' => $startDate);
if ($org !== 'all') $conditions['org'] = $org;
$validDates = $this->Log->find('all', array(
'fields' => array('created'),
'conditions' => $conditions,
));
$data = array();
foreach ($validDates as $k => $date) {
$temp = strtotime("0:00", strtotime($date['Log']['created']));
if (array_key_exists($temp, $data)) {
$data[$temp]++;
} else {
$data[$temp] = 1;
}
}
$this->set('data', $data);
$this->set('_serialize', 'data');
}
}

View File

@ -743,4 +743,23 @@ class UsersController extends AppController {
}
// User didn't see the contact form yet. Present it to him.
}
// shows some statistics about the instance
public function statistics() {
$this->User->recursive = -1;
$orgs = $this->User->find('all', array('fields' => array('DISTINCT (org) AS org')));
$this->loadModel('Log');
$year = date('Y');
$month = date('n');
$day = date('j');
$month = $month - 5;
if ($month < 1) {
$year--;
$month = 12 + $month;
}
$this->set('orgs', $orgs);
$this->set('start', strtotime(date('Y-m-d H:i:s') . ' -5 months'));
$this->set('end', strtotime(date('Y-m-d H:i:s')));
$this->set('startDateCal', $year . ', ' . $month . ', 01');
}
}

View File

@ -107,6 +107,7 @@
<li <?php if ($menuItem === 'members') echo 'class="active";'?>><a href="/users/memberslist">Members List</a></li>
<li <?php if ($menuItem === 'userGuide') echo 'class="active";'?>><a href="/pages/display/doc/general">User Guide</a></li>
<li <?php if ($menuItem === 'terms') echo 'class="active";'?>><a href="/users/terms">Terms &amp; Conditions</a></li>
<li <?php if ($menuItem === 'statistics') echo 'class="active";'?>><a href="/users/statistics">Statistics</a></li>
<?php
break;