diff options
Diffstat (limited to 'perl-lib/PgCommitFest/CommitFest.pm')
-rw-r--r-- | perl-lib/PgCommitFest/CommitFest.pm | 34 |
1 files changed, 31 insertions, 3 deletions
diff --git a/perl-lib/PgCommitFest/CommitFest.pm b/perl-lib/PgCommitFest/CommitFest.pm index de19005..a4115b2 100644 --- a/perl-lib/PgCommitFest/CommitFest.pm +++ b/perl-lib/PgCommitFest/CommitFest.pm @@ -86,11 +86,39 @@ EOM } sub view { - my ($r) = @_; + my ($r, $extrapath) = @_; my $aa = $r->authenticate(); + + # Target commitfest can be specified either by ID, or we allow special + # magic to fetch it by my $id = $r->cgi_id(); - my $d = $r->db->select_one(<<EOM, $id) if defined $id; -SELECT id, name, commitfest_status FROM commitfest_view WHERE id = ? + my $sqlbit; + if (defined $id) { + $sqlbit = "WHERE id = " . $r->db->quote($id); + } + elsif (defined $extrapath) { + if ($extrapath eq 'open') { + $sqlbit = + "WHERE commitfest_status_id = 2 ORDER BY name DESC LIMIT 1"; + } + elsif ($extrapath eq 'inprogress') { + $sqlbit = <<EOM; +WHERE commitfest_status_id IN (2, 3) + ORDER BY commitfest_status_id DESC, name DESC LIMIT 1 +EOM + } + elsif ($extrapath eq 'previous') { + $sqlbit = + "WHERE commitfest_status_id = 4 ORDER BY name DESC LIMIT 1"; + } + } + if (!defined $sqlbit) { + $r->error_exit("Unable to identify target CommitFest."); + } + + # Fetch target commitfest from database. + my $d = $r->db->select_one(<<EOM); +SELECT id, name, commitfest_status FROM commitfest_view $sqlbit EOM $r->error_exit('CommitFest not found.') if !defined $d; $r->set_title('CommitFest %s (%s)', $d->{'name'}, |