diff options
author | Robert Haas | 2010-08-10 17:49:30 +0000 |
---|---|---|
committer | Robert Haas | 2010-08-10 17:49:30 +0000 |
commit | b3735ecca50610b4f569f33438e3c015bc59674e (patch) | |
tree | 9747baad077354d5c9c29e18e85fefc70eded76c | |
parent | 3cb6c3d040d3705562838f8715ea1f84ef2700f2 (diff) |
Allow CommitFest view to be filtered by patch status.
-rw-r--r-- | perl-lib/PgCommitFest/CommitFest.pm | 25 | ||||
-rw-r--r-- | template/commitfest_view.tt2 | 10 |
2 files changed, 30 insertions, 5 deletions
diff --git a/perl-lib/PgCommitFest/CommitFest.pm b/perl-lib/PgCommitFest/CommitFest.pm index a04c72f..049bd99 100644 --- a/perl-lib/PgCommitFest/CommitFest.pm +++ b/perl-lib/PgCommitFest/CommitFest.pm @@ -213,6 +213,20 @@ sub view { $r->set_title('CommitFest %s (%s)', $d->{'name'}, $d->{'commitfest_status'}); + # Filtering. + my $filter_sql = ''; + my @filter_text; + my $status; + if (defined $r->cgi_id('status')) { + $status = $r->db->select_one(<<EOM, $r->cgi_id('status')); +SELECT id, name FROM patch_status WHERE id = ? +EOM + $r->error_exit('Unknown status.') if !defined $status; + $filter_sql .= sprintf(' AND patch_status_id = %s', $status->{'id'}); + push @filter_text, + sprintf 'Filtering on status "%s".', $status->{'name'}; + } + # Load list of patches. my $previous_topic; my %patch_grouping; @@ -220,7 +234,7 @@ sub view { my $patch_list = $r->db->select(<<EOM, $d->{'id'}); SELECT id, name, patch_status_id, patch_status, author, reviewers, commitfest_topic_id, commitfest_topic, commitfest_id, date_closed -FROM patch_view WHERE commitfest_id = ? +FROM patch_view WHERE commitfest_id = ? $filter_sql ORDER BY date_closed, commitfest_topic_sortorder, commitfest_topic, id EOM for my $p (@$patch_list) { @@ -253,10 +267,14 @@ EOM } # Load status counts. + my $total_count = 0; my $status_count_list = $r->db->select(<<EOM, $d->{'id'}); SELECT patch_status_id, patch_status, sum(1) AS num_patches from patch_view WHERE commitfest_id = ? GROUP BY 1, 2 ORDER BY 1 EOM + for my $scl (@$status_count_list) { + $total_count += $scl->{'num_patches'}; + } # Add links. $r->add_link('/action/patch_form?commitfest=' . $id, 'New Patch'); @@ -272,8 +290,9 @@ EOM # Render template. $r->render_template('commitfest_view', { - 'd' => $d, 'status_count_list' => $status_count_list, - 'total_count' => 0+@$patch_list, + 'd' => $d, 'filter_text' => \@filter_text, + 'status_count_list' => $status_count_list, + 'total_count' => $total_count, 'patch_grouping' => [ { 'name' => 'Pending Patches', diff --git a/template/commitfest_view.tt2 b/template/commitfest_view.tt2 index 5e4db85..d1d3fd3 100644 --- a/template/commitfest_view.tt2 +++ b/template/commitfest_view.tt2 @@ -2,15 +2,20 @@ view all the comments for a particular patch, or to add a comment or make other changes, click on the patch name.</p> +[% IF filter_text.size > 0 %] +<p style='color: #00f; font-weight: bold'>[% FOREACH f = filter_text %][% f | html %][% END %]</p> +[% END %] + [% IF status_count_list.size > 0 %] <p><b>Status Summary</b>. [% FOREACH sc = status_count_list %] -[% sc.patch_status %]: [% sc.num_patches %][% IF !loop.last %],[% ELSE %].[% END %] -[% END %] Total: [% total_count %]. +<a href='/action/commitfest_view?id=[% d.id %]&status=[% sc.patch_status_id %]'>[% sc.patch_status %]</a>: [% sc.num_patches %][% IF !loop.last %],[% ELSE %].[% END %] +[% END %] <a href='/action/commitfest_view?id=[% d.id %]'>Total</a>: [% total_count %]. </p> [% END %] [% FOREACH g = patch_grouping %] +[% IF g.patch_list.size > 0 || filter_text.size == 0 %] <h2>[% g.name | htmlsafe %]</h2> [% IF g.patch_list.size %] @@ -48,5 +53,6 @@ changes, click on the patch name.</p> [% ELSE %] <div>No patches.</div> [% END %] +[% END %] [% END %] |