From 6f51d21f0ab443a79141c00a0f9f6eca06dc9551 Mon Sep 17 00:00:00 2001 From: Andrew Dunstan Date: Sun, 11 Dec 2011 08:28:50 -0800 Subject: [PATCH] Allow "latest" as the date of a stage log. This allows construction of a static URL that points to the latest docs build log, as requested by Magnus and Tom. --- cgi-bin/show_stage_log.pl | 19 ++++++++++++++++--- 1 file changed, 16 insertions(+), 3 deletions(-) diff --git a/cgi-bin/show_stage_log.pl b/cgi-bin/show_stage_log.pl index 7fd6438..8110995 100755 --- a/cgi-bin/show_stage_log.pl +++ b/cgi-bin/show_stage_log.pl @@ -32,6 +32,7 @@ my $query = new CGI; my $system = $query->param('nm'); $system =~ s/[^a-zA-Z0-9_ -]//g; my $logdate = $query->param('dt');$logdate =~ s/[^a-zA-Z0-9_ -]//g; my $stage = $query->param('stg');$stage =~ s/[^a-zA-Z0-9._ -]//g; +my $brnch = $query->param('branch') || 'HEAD'; $brnch =~ s/[^a-zA-Z0-9._ -]//g; use vars qw($tgz); @@ -41,6 +42,20 @@ if ($system && $logdate && $stage) die $DBI::errstr unless $db; + if ($logdate =~ /^latest$/i) + { + my $find_latest = qq{ + select max(snapshot) + from build_status_log + where sysname = ? + and snapshot > now() - interval '30 days' + and log_stage = ? || '.log' + and branch = ? + }; + my $logs = $db->selectcol_arrayref($find_latest,undef,$system,$stage,$brnch); + $logdate = shift(@$logs); + } + my $statement = q( select branch, log_text @@ -48,8 +63,6 @@ if ($system && $logdate && $stage) where sysname = ? and snapshot = ? and log_stage = ? || '.log' ); - - my $sth=$db->prepare($statement); $sth->execute($system,$logdate,$stage); @@ -63,7 +76,7 @@ if ($system && $logdate && $stage) $sth->finish; $db->disconnect; - print "Content-Type: text/plain\n\n", $logtext, + print "Content-Type: text/plain\n\nSnapshot: $logdate\n\n", $logtext, "-------------------------------------------------\n\n", "Hosting for the PostgreSQL Buildfarm is generously ", -- 2.30.2