Added grid, region stats
This commit is contained in:
46
htdocs/lib/CrashStats.php
Normal file
46
htdocs/lib/CrashStats.php
Normal file
@@ -0,0 +1,46 @@
|
||||
<?php
|
||||
|
||||
class CrashStats
|
||||
{
|
||||
var $filter;
|
||||
|
||||
function __construct($filter = null)
|
||||
{
|
||||
$this->filter = $filter;
|
||||
}
|
||||
|
||||
function setFilter($filter)
|
||||
{
|
||||
$this->filter = $filter;
|
||||
}
|
||||
|
||||
function getRegionStats()
|
||||
{
|
||||
$ret = array();
|
||||
$where = $this->filter->getWhere();
|
||||
if ($where)
|
||||
{
|
||||
$where .= " and ";
|
||||
}
|
||||
else
|
||||
{
|
||||
$where = "where ";
|
||||
}
|
||||
$where .= "region is not null and grid is not null";
|
||||
$q = "select count(id) as nr, region, grid from reports $where group by region, grid 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;
|
||||
}
|
||||
}
|
||||
@@ -6,17 +6,30 @@ class SearchFilter
|
||||
public $chan;
|
||||
public $version;
|
||||
public $grid;
|
||||
public $region;
|
||||
public $gpu;
|
||||
public $stacktrace;
|
||||
|
||||
public $sort_by;
|
||||
public $sort_order;
|
||||
public static $sort_keys = array("date", "os", "version", "grid");
|
||||
public static $sort_orders = array("asc", "desc");
|
||||
public $limit = 100;
|
||||
public $limit = 50;
|
||||
public $offset = 0;
|
||||
public $page = 0;
|
||||
|
||||
var $fields = array("os", "chan", "version", "grid", "region", "gpu", "stacktrace");
|
||||
|
||||
function __construct()
|
||||
{
|
||||
foreach($this->fields as $field)
|
||||
{
|
||||
if (strlen($_GET[$field]))
|
||||
{
|
||||
$this->$field = trim($_GET[$field]);
|
||||
}
|
||||
}
|
||||
|
||||
if (in_array($_GET["sort_by"], self::$sort_keys))
|
||||
{
|
||||
$this->sort_by = $_GET["sort_by"];
|
||||
@@ -27,34 +40,30 @@ class SearchFilter
|
||||
$this->sort_by = $_GET["sort_order"];
|
||||
}
|
||||
|
||||
if (strlen($_GET["os"]))
|
||||
{
|
||||
$this->os = $_GET["os"];
|
||||
}
|
||||
|
||||
if (strlen($_GET["chan"]))
|
||||
{
|
||||
$this->chan = $_GET["chan"];
|
||||
}
|
||||
|
||||
if (strlen($_GET["version"]))
|
||||
{
|
||||
$this->version = $_GET["version"];
|
||||
}
|
||||
|
||||
if (strlen($_GET["page"]))
|
||||
{
|
||||
$this->page = $_GET["page"];
|
||||
}
|
||||
|
||||
if (strlen($_GET["grid"]))
|
||||
}
|
||||
|
||||
function getURLArgs()
|
||||
{
|
||||
$cond = array();
|
||||
foreach($this->fields as $field)
|
||||
{
|
||||
$this->grid = $_GET["grid"];
|
||||
if ($this->$field)
|
||||
{
|
||||
$cond[] = $field . "=" . urlencode($this->$field);
|
||||
}
|
||||
}
|
||||
|
||||
if (strlen($_GET["stacktrace"]))
|
||||
|
||||
if (!count($cond))
|
||||
{
|
||||
$this->stacktrace = $_GET["stacktrace"];
|
||||
return "";
|
||||
}
|
||||
else
|
||||
{
|
||||
return implode("&", $cond);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -65,6 +74,8 @@ class SearchFilter
|
||||
if ($this->version) $cond[] = kl_str_sql("client_version=!s", $this->version);
|
||||
if ($this->chan) $cond[] = kl_str_sql("client_channel=!s", $this->chan);
|
||||
if ($this->grid) $cond[] = kl_str_sql("grid=!s", $this->grid);
|
||||
if ($this->region) $cond[] = kl_str_sql("region=!s", $this->region);
|
||||
if ($this->gpu) $cond[] = kl_str_sql("gpu=!s", $this->gpu);
|
||||
|
||||
if ($this->stacktrace)
|
||||
{
|
||||
@@ -193,6 +204,15 @@ for($i = 0; $i < count($grids); $i++)
|
||||
<input class="ui-widget-content toolbarbutton" type="submit" name="do_search" value="Search" />
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<?php if ($this->region): ?>
|
||||
<input type="hidden" name="region" value="<?php echo htmlentities($this->region) ?>" />
|
||||
<?php endif ?>
|
||||
|
||||
<?php if ($this->gpu): ?>
|
||||
<input type="hidden" name="gpu" value="<?php echo htmlentities($this->gpu) ?>" />
|
||||
<?php endif ?>
|
||||
|
||||
</form>
|
||||
|
||||
<?php
|
||||
|
||||
@@ -3,15 +3,17 @@
|
||||
define("SITE_ROOT", realpath(dirname(__file__)));
|
||||
require_once SITE_ROOT . "/lib/init.php";
|
||||
$S->requireUser();
|
||||
|
||||
$filter = new SearchFilter();
|
||||
$stats = new CrashStats($filter);
|
||||
|
||||
Layout::header();
|
||||
$filter->render();
|
||||
?>
|
||||
<script>
|
||||
$(function() {
|
||||
$( "#tabs" ).tabs({ active: 1 });
|
||||
// $("div.ui-tabs-panel").css('padding','0px');
|
||||
$( "#tabs" ).tabs();
|
||||
//$("div.ui-tabs-panel").css('padding','0px');
|
||||
});
|
||||
</script>
|
||||
<br/>
|
||||
@@ -44,6 +46,32 @@ $filter->render();
|
||||
|
||||
<!-- regions tab -->
|
||||
<div id="tab-4">
|
||||
<?php
|
||||
function rl($r)
|
||||
{
|
||||
global $filter;
|
||||
return URL_ROOT . "/crashes.php?" . $filter->getURLArgs() . "®ion=" . urlencode($r->region) . "&grid=" . urlencode($r->grid);
|
||||
}
|
||||
$regions = $stats->getRegionStats();
|
||||
$c = count($regions);
|
||||
if ($c) :
|
||||
?>
|
||||
<table class="jtable">
|
||||
<tr>
|
||||
<th>Nr. reports</th>
|
||||
<th>Region</th>
|
||||
<th>Grid</th>
|
||||
</tr>
|
||||
<?php foreach($regions as $r): ?>
|
||||
<tr class="rowhighlight">
|
||||
<td style="text-align: right"><a href="<?php echo rl($r) ?>"><?php echo htmlentities($r->nr) ?></a></td>
|
||||
<td><a href="<?php echo rl($r) ?>"><?php echo htmlentities($r->region) ?></a></td>
|
||||
<td><a href="<?php echo rl($r) ?>"><?php echo htmlentities($r->grid) ?></a></td>
|
||||
</tr>
|
||||
<?php endforeach ?>
|
||||
</table>
|
||||
|
||||
<?php endif ?>
|
||||
</div>
|
||||
<!-- /regions tab -->
|
||||
</div>
|
||||
|
||||
Reference in New Issue
Block a user