diff --git a/htdocs/lib/CrashReport.php b/htdocs/lib/CrashReport.php index 50d42e6..0b8e3d2 100644 --- a/htdocs/lib/CrashReport.php +++ b/htdocs/lib/CrashReport.php @@ -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, diff --git a/htdocs/lib/CrashStats.php b/htdocs/lib/CrashStats.php index 33b3d29..2e9abf0 100644 --- a/htdocs/lib/CrashStats.php +++ b/htdocs/lib/CrashStats.php @@ -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)) diff --git a/htdocs/lib/Memc.php b/htdocs/lib/Memc.php index f5ed774..8037665 100644 --- a/htdocs/lib/Memc.php +++ b/htdocs/lib/Memc.php @@ -3,7 +3,7 @@ class Memc { static $mem; static $active = false; - static $expire = 3600; + static $expire = 7200; function init() { diff --git a/htdocs/lib/db_init.sql b/htdocs/lib/db_init.sql index 0b73b6a..cd8e24e 100644 --- a/htdocs/lib/db_init.sql +++ b/htdocs/lib/db_init.sql @@ -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) -); \ No newline at end of file +); + +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 ; \ No newline at end of file diff --git a/htdocs/statistics.php b/htdocs/statistics.php index 9feef96..55ca88a 100644 --- a/htdocs/statistics.php +++ b/htdocs/statistics.php @@ -7,7 +7,7 @@ $S->requireUser(); $filter = new SearchFilter(); $stats = new CrashStats($filter); -Layout::header(); +Layout::header($filter->renderPaginator($stats->getNumTopCrashers())); $filter->render(); ?>