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);
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
where sysname = ? and snapshot = ? and log_stage = ? || '.log'
);
-
-
my $sth=$db->prepare($statement);
$sth->execute($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 ",