From b3735ecca50610b4f569f33438e3c015bc59674e Mon Sep 17 00:00:00 2001 From: Robert Haas Date: Tue, 10 Aug 2010 13:49:30 -0400 Subject: [PATCH] Allow CommitFest view to be filtered by patch status. --- perl-lib/PgCommitFest/CommitFest.pm | 25 ++++++++++++++++++++++--- 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(<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(<{'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(<{'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.

+[% IF filter_text.size > 0 %] +

[% FOREACH f = filter_text %][% f | html %][% END %]

+[% END %] + [% IF status_count_list.size > 0 %]

Status Summary. [% FOREACH sc = status_count_list %] -[% sc.patch_status %]: [% sc.num_patches %][% IF !loop.last %],[% ELSE %].[% END %] -[% END %] Total: [% total_count %]. +[% sc.patch_status %]: [% sc.num_patches %][% IF !loop.last %],[% ELSE %].[% END %] +[% END %] Total: [% total_count %].

[% END %] [% FOREACH g = patch_grouping %] +[% IF g.patch_list.size > 0 || filter_text.size == 0 %]

[% g.name | htmlsafe %]

[% IF g.patch_list.size %] @@ -48,5 +53,6 @@ changes, click on the patch name.

[% ELSE %]
No patches.
[% END %] +[% END %] [% END %] -- 2.39.5