Paging on stats signature page, inserting sql sort friendly version number
This commit is contained in:
@@ -129,6 +129,18 @@ class CrashReport
|
||||
DBH::$db->query(kl_str_sql("delete from reports where id=!i", $this->id));
|
||||
}
|
||||
|
||||
static function sortableVersion($v)
|
||||
{
|
||||
$parts = explode(".", $v);
|
||||
$ret = "";
|
||||
foreach($parts as $p)
|
||||
{
|
||||
$ret .= sprintf("%06d", (int)$p);
|
||||
}
|
||||
|
||||
return $ret;
|
||||
}
|
||||
|
||||
function save()
|
||||
{
|
||||
$this->delete();
|
||||
@@ -136,6 +148,7 @@ class CrashReport
|
||||
id,
|
||||
reported,
|
||||
client_version,
|
||||
client_version_s,
|
||||
client_channel,
|
||||
os,
|
||||
os_type,
|
||||
@@ -150,10 +163,11 @@ class CrashReport
|
||||
crash_address,
|
||||
crash_thread,
|
||||
raw_stacktrace
|
||||
) values (!i, !t, !s, !s, !s, !s, !s, !s, !s, !s, !i, !s, !s, !s, !s, !i, !s)",
|
||||
) values (!i, !t, !s, !s, !s, !s, !s, !s, !s, !s, !s, !i, !s, !s, !s, !s, !i, !s)",
|
||||
$this->id,
|
||||
$this->reported,
|
||||
$this->client_version,
|
||||
self::sortableVersion($this->client_version),
|
||||
$this->client_channel,
|
||||
$this->os,
|
||||
$this->os_type,
|
||||
|
||||
@@ -20,13 +20,34 @@ class CrashStats
|
||||
{
|
||||
$this->filter = $filter;
|
||||
}
|
||||
|
||||
function getNumTopCrashers()
|
||||
{
|
||||
$ret = 0;
|
||||
$where = $this->filter->getWhere();
|
||||
$q = "select count(1) as total from (select s.id from reports r join signature s on r.signature_id = s.id $where group by signature_id) as reports";
|
||||
if (false !== $cached = Memc::getq($q)) return $cached;
|
||||
|
||||
if (!$res = DBH::$db->query($q))
|
||||
{
|
||||
return $ret;
|
||||
}
|
||||
|
||||
if ($row = DBH::$db->fetchRow($res))
|
||||
{
|
||||
$ret = (int)$row["total"];
|
||||
}
|
||||
|
||||
Memc::setq($q, $ret);
|
||||
return $ret;
|
||||
}
|
||||
|
||||
function getTopCrashers()
|
||||
{
|
||||
$ret = array();
|
||||
$where = $this->filter->getWhere();
|
||||
$q = "select count(r.id) as nr, s.id as signature_id, s.signature as signature_text, s.has_comments from reports r join signature s on r.signature_id = s.id $where group by signature_id order by nr desc";
|
||||
$q .= kl_str_sql(" limit !i", 100);
|
||||
$q .= kl_str_sql(" limit !i offset !i", $this->filter->limit, $this->filter->offset);
|
||||
if (false !== $cached = Memc::getq($q)) return $cached;
|
||||
|
||||
if (!$res = DBH::$db->query($q))
|
||||
|
||||
@@ -3,7 +3,7 @@ class Memc
|
||||
{
|
||||
static $mem;
|
||||
static $active = false;
|
||||
static $expire = 3600;
|
||||
static $expire = 7200;
|
||||
|
||||
function init()
|
||||
{
|
||||
|
||||
@@ -38,6 +38,7 @@ create table reports(
|
||||
id integer not null primary key,
|
||||
reported timestamp,
|
||||
client_version varchar(32),
|
||||
client_version_s varchar(32),
|
||||
client_channel varchar(32),
|
||||
os varchar(128),
|
||||
os_type varchar(32),
|
||||
@@ -78,4 +79,22 @@ create table builds(
|
||||
hash varchar(64),
|
||||
modified timestamp,
|
||||
primary key(chan, build_nr)
|
||||
);
|
||||
);
|
||||
|
||||
drop function ver_expand;
|
||||
|
||||
delimiter $$
|
||||
create function ver_expand(ver varchar(32))
|
||||
returns varchar(32) deterministic
|
||||
begin
|
||||
declare ret varchar(32);
|
||||
declare i int;
|
||||
set i = 1;
|
||||
set ret = '';
|
||||
while (i < 5) do
|
||||
set ret = concat(ret, SUBSTRING_INDEX(SUBSTRING_INDEX(ver , '.', i ),'.',-1));
|
||||
set i = i + 1;
|
||||
end while;
|
||||
return ret;
|
||||
end$$
|
||||
delimiter ;
|
||||
@@ -7,7 +7,7 @@ $S->requireUser();
|
||||
$filter = new SearchFilter();
|
||||
$stats = new CrashStats($filter);
|
||||
|
||||
Layout::header();
|
||||
Layout::header($filter->renderPaginator($stats->getNumTopCrashers()));
|
||||
$filter->render();
|
||||
?>
|
||||
<script>
|
||||
|
||||
Reference in New Issue
Block a user