[bugzilla-gnome-org-extensions] Add the "Popular Traces" page.
- From: Krzesimir Nowak <krnowak src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [bugzilla-gnome-org-extensions] Add the "Popular Traces" page.
- Date: Thu, 20 Nov 2014 22:13:31 +0000 (UTC)
commit 7abc4875b1d4361e6c9004059185982931e0317d
Author: Max Kanat-Alexander <mkanat everythingsolved com>
Date: Thu Aug 6 03:34:33 2009 -0500
Add the "Popular Traces" page.
lib/TraceParser/Hooks.pm | 31 +++++++++++++++-
template/en/default/pages/popular-traces.html.tmpl | 39 ++++++++++++++++++++
2 files changed, 69 insertions(+), 1 deletions(-)
---
diff --git a/lib/TraceParser/Hooks.pm b/lib/TraceParser/Hooks.pm
index c073993..392b067 100644
--- a/lib/TraceParser/Hooks.pm
+++ b/lib/TraceParser/Hooks.pm
@@ -32,6 +32,8 @@ our @EXPORT = qw(
page
);
+use constant DEFAULT_POPULAR_LIMIT => 20;
+
sub install_update_db {
my $dbh = Bugzilla->dbh;
my $has_traces = $dbh->selectrow_array('SELECT 1 FROM trace '
@@ -111,7 +113,17 @@ sub format_comment {
sub page {
my %params = @_;
my ($vars, $page) = @params{qw(vars page_id)};
- return if $page !~ '^trace\.';
+ if ($page =~ '^trace\.') {
+ _page_trace($vars);
+ }
+ elsif ($page =~ '^popular-traces\.') {
+ _page_popular_traces($vars);
+ }
+}
+
+sub _page_trace {
+ my $vars = shift;
+
my $trace_id = Bugzilla->cgi->param('trace_id');
my $trace = TraceParser::Trace->check({ id => $trace_id });
$trace->bug->check_is_visible;
@@ -133,4 +145,21 @@ sub page {
$vars->{trace} = $trace;
}
+sub _page_popular_traces {
+ my $vars = shift;
+ my $limit = Bugzilla->cgi->param('limit') || DEFAULT_POPULAR_LIMIT;
+ my $dbh = Bugzilla->dbh;
+ my %trace_count = @{ $dbh->selectcol_arrayref(
+ 'SELECT MAX(id), COUNT(*) AS trace_count
+ FROM trace WHERE short_hash IS NOT NULL
+ GROUP BY short_hash ORDER BY trace_count DESC '
+ . $dbh->sql_limit('?'), {Columns=>[1,2]}, $limit) };
+
+ my @traces = map { new TraceParser::Trace($_) } (keys %trace_count);
+ @traces = reverse sort { $trace_count{$a->id} <=> $trace_count{$b->id} }
+ @traces;
+ $vars->{traces} = \ traces;
+ $vars->{trace_count} = \%trace_count;
+}
+
1;
diff --git a/template/en/default/pages/popular-traces.html.tmpl
b/template/en/default/pages/popular-traces.html.tmpl
new file mode 100644
index 0000000..429baff
--- /dev/null
+++ b/template/en/default/pages/popular-traces.html.tmpl
@@ -0,0 +1,39 @@
+[%#
+ # The contents of this file are subject to the Mozilla Public
+ # License Version 1.1 (the "License"); you may not use this file
+ # except in compliance with the License. You may obtain a copy of
+ # the License at http://www.mozilla.org/MPL/
+ #
+ # Software distributed under the License is distributed on an "AS
+ # IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or
+ # implied. See the License for the specific language governing
+ # rights and limitations under the License.
+ #
+ # The Original Code is the Bugzilla TraceParser Plugin.
+ #
+ # The Initial Developer of the Original Code is Canonical Ltd.
+ # Portions created by Canonical Ltd. are Copyright (C) 2009
+ # Canonical Ltd. All Rights Reserved.
+ #
+ # Contributor(s):
+ # Max Kanat-Alexander <mkanat bugzilla org>
+ #%]
+
+[% PROCESS global/header.html.tmpl
+ title = "Most Popular Traces"
+%]
+
+<p>Most popular traces (as determined by comparing their first few
+ functions):</p>
+
+<ul class="trace_list">
+ [% FOREACH trace = traces %]
+ <li>
+ <a href="page.cgi?id=trace.html&trace_id=
+ [%- trace.id FILTER url_quote %]">
+ [%- trace_count.${trace.id} FILTER html %]</a>:
+ [%+ trace.short_stack.join(", ") FILTER html %]</li>
+ [% END %]
+</ul>
+
+[% PROCESS global/footer.html.tmpl %]
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]