Added operating system stats

This commit is contained in:
Latif Khalifa
2013-10-12 03:53:37 +02:00
parent 9f217795c3
commit 2cfede8c3c
2 changed files with 54 additions and 0 deletions

View File

@@ -13,6 +13,36 @@ class CrashStats
{
$this->filter = $filter;
}
function getOSStats()
{
$ret = array();
$where = $this->filter->getWhere();
if ($where)
{
$where .= " and ";
}
else
{
$where = "where ";
}
$where .= "os_type is not null";
$q = "select count(id) as nr, os_type from reports $where group by os_type order by nr desc";
$q .= kl_str_sql(" limit !i", $this->filter->limit);
if (false !== $cached = Memc::getq($q)) return $cached;
if (!$res = DBH::$db->query($q)) return $ret;
while ($row = DBH::$db->fetchRow($res))
{
$o = new stdClass;
DBH::$db->loadFromDbRow($o, $res, $row);
$ret[] = $o;
}
Memc::setq($q, $ret);
return $ret;
}
function getRegionStats()
{

View File

@@ -40,6 +40,30 @@ $filter->render();
<!-- os tab -->
<div id="tab-3">
<?php
function rl_o($r)
{
global $filter;
return URL_ROOT . "/crashes.php?" . $filter->getURLArgs() . "&os=" . urlencode($r->os_type);
}
$oses = $stats->getOSStats();
$c = count($oses);
if ($c) :
?>
<table class="jtable">
<tr>
<th>Nr. reports</th>
<th>Operating System Type</th>
</tr>
<?php foreach($oses as $r): ?>
<tr class="rowhighlight">
<td style="text-align: right"><a href="<?php echo rl_o($r) ?>"><?php echo htmlentities($r->nr) ?></a></td>
<td><a href="<?php echo rl_o($r) ?>"><?php echo htmlentities($r->os_type) ?></a></td>
</tr>
<?php endforeach ?>
</table>
<?php endif ?>
</div>
<!-- /os tab -->