diff options
author | Robert Haas | 2009-07-04 00:05:17 +0000 |
---|---|---|
committer | Robert Haas | 2009-07-04 00:05:17 +0000 |
commit | 62159b9e086d901b37e9b7ca1d2b58264e4f574e (patch) | |
tree | 8c59cb2f66025019126b2f871d6c5216a619008e /perl-lib/PgCommitFest | |
parent | 2aec1f66cb27bd3452592003a68e614fab220df1 (diff) |
Stable links for open, in-progress, and previous CommitFests.
Diffstat (limited to 'perl-lib/PgCommitFest')
-rw-r--r-- | perl-lib/PgCommitFest/CommitFest.pm | 34 | ||||
-rw-r--r-- | perl-lib/PgCommitFest/DB.pm | 5 |
2 files changed, 36 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'}, diff --git a/perl-lib/PgCommitFest/DB.pm b/perl-lib/PgCommitFest/DB.pm index 0cd3b7d..4719007 100644 --- a/perl-lib/PgCommitFest/DB.pm +++ b/perl-lib/PgCommitFest/DB.pm @@ -89,6 +89,11 @@ sub insert_returning_id { return $result->{'id'}; } +sub quote { + my ($self, $value) = @_; + return $self->{'dbh'}->quote($value); +} + sub rollback { my ($self) = @_; $self->{'dirty'} = 0; |