require "$ENV{BFConfDir}/BuildFarmWeb.pl";
my $query = new CGI;
-my @members = $query->param('member');
+my @members = grep {$_ ne "" } $query->param('member');
map { s/[^a-zA-Z0-9_ -]//g; } @members;
+my $max_days = $query->param('max_days') + 0 || 10;
+my @branches = grep {$_ ne "" } $query->param('branch');
+map { s/[^a-zA-Z0-9_ -]//g; } @branches;
+my @stages = grep {$_ ne "" } $query->param('stage');
+map { s/[^a-zA-Z0-9_ :-]//g; } @stages;
my $dsn="dbi:Pg:dbname=$dbname";
$dsn .= ";host=$dbhost" if $dbhost;
my $db = DBI->connect($dsn,$dbuser,$dbpass,{pg_expand_array => 0})
or die("$dsn,$dbuser,$dbpass,$!");
+my $get_all_branches = qq{
+
+ select distinct branch
+ from nrecent_failures
+ where branch <> 'HEAD'
+ order by branch desc
+
+};
+
+my $all_branches = $db->selectcol_arrayref($get_all_branches);
+unshift (@$all_branches,'HEAD');
+
+my $get_all_members = qq{
+
+ select distinct sysname
+ from nrecent_failures
+ order by sysname
+
+};
+
+my $all_members = $db->selectcol_arrayref($get_all_members);
+
+my $get_all_stages = qq{
+
+ select distinct stage
+ from build_status
+ join nrecent_failures using (sysname,snapshot,branch)
+
+};
+
+my $all_stages = $db->selectcol_arrayref($get_all_stages);
+
my $statement =<<EOS;
from nrecent_failures_db_data b
left join dashboard_mat d
on (d.sysname = b.sysname and d.branch = b.branch)
+ where (now()::timestamp(0) without time zone - b.snapshot) < (? * interval '1 day')
order by $presort_clause
b.branch = 'HEAD' desc,
b.branch desc,
my $statrows=[];
my $sth=$db->prepare($statement);
-$sth->execute;
+$sth->execute($max_days);
while (my $row = $sth->fetchrow_hashref)
{
next if (@members && ! grep {$_ eq $row->{sysname} } @members);
+ next if (@stages && ! grep {$_ eq $row->{stage} } @stages);
+ next if (@branches && ! grep {$_ eq $row->{branch} } @branches);
$row->{build_flags} =~ s/^\{(.*)\}$/$1/;
$row->{build_flags} =~ s/,/ /g;
# enable-integer-datetimes is now the default
$template->process('fstatus.tt',
{statrows=>$statrows,
sortby => $sortby,
- members=> \@members} );
+ max_days => $max_days,
+ all_branches => $all_branches,
+ all_members => $all_members,
+ all_stages => $all_stages,
+ qmembers=> \@members,
+ qbranches => \@branches,
+ qstages => \@stages} );
exit;