5 Copyright (c) 2003-2010, Andrew Dunstan
7 See accompanying License file for license details
16 use vars qw($dbhost $dbname $dbuser $dbpass $dbport $template_dir);
18 use FindBin qw($RealBin);
19 require "$RealBin/../BuildFarmWeb.pl";
22 my @members = grep {$_ ne "" } $query->multi_param('member');
23 map { s/[^a-zA-Z0-9_ -]//g; } @members;
24 my $max_days = $query->param('max_days') + 0 || 10;
25 my @branches = grep {$_ ne "" } $query->multi_param('branch');
26 map { s/[^a-zA-Z0-9+_ .-]//g; } @branches;
27 my @stages = grep {$_ ne "" } $query->multi_param('stage');
28 map { s/[^a-zA-Z0-9_ :-]//g; } @stages;
30 my $dsn="dbi:Pg:dbname=$dbname";
31 $dsn .= ";host=$dbhost" if $dbhost;
32 $dsn .= ";port=$dbport" if $dbport;
36 my $presort_clause = "";
37 my $sortby = $query->param('sortby') || 'nosort';
38 if ($sortby eq 'name')
40 $sort_clause = 'lower(b.sysname),';
42 elsif ($sortby eq 'namenobranch')
44 $presort_clause = "lower(b.sysname), b.snapshot desc,"
47 my $db = DBI->connect($dsn,$dbuser,$dbpass,{pg_expand_array => 0})
48 or die("$dsn,$dbuser,$dbpass,$!");
50 my $get_all_branches = qq{
52 select distinct branch
54 where branch <> 'HEAD'
59 my $all_branches = $db->selectcol_arrayref($get_all_branches);
60 unshift (@$all_branches,'HEAD');
62 my $get_all_members = qq{
64 select distinct sysname
70 my $all_members = $db->selectcol_arrayref($get_all_members);
72 my $get_all_stages = qq{
74 select distinct build_status.stage
76 join nrecent_failures using (sysname,snapshot,branch)
80 my $all_stages = $db->selectcol_arrayref($get_all_stages);
85 select timezone('GMT'::text,
86 now())::timestamp(0) without time zone - b.snapshot AS when_ago,
88 d.stage as current_stage
89 from nrecent_failures_db_data b
90 left join dashboard_mat d
91 on (d.sysname = b.sysname and d.branch = b.branch)
92 where (now()::timestamp(0) without time zone - b.snapshot) < (? * interval '1 day')
93 order by $presort_clause
94 b.branch = 'HEAD' desc,
103 my $sth=$db->prepare($statement);
104 $sth->execute($max_days);
105 while (my $row = $sth->fetchrow_hashref)
107 next if (@members && ! grep {$_ eq $row->{sysname} } @members);
108 next if (@stages && ! grep {$_ eq $row->{stage} } @stages);
109 next if (@branches && ! grep {$_ eq $row->{branch} } @branches);
110 $row->{build_flags} =~ s/^\{(.*)\}$/$1/;
111 $row->{build_flags} =~ s/,/ /g;
112 ## # enable-integer-datetimes is now the default
113 ## if ($row->{branch} eq 'HEAD' || $row->{branch} gt 'REL8_3_STABLE')
115 ## $row->{build_flags} .= " --enable-integer-datetimes "
116 ## unless ($row->{build_flags} =~ /--(en|dis)able-integer-datetimes/);
118 ## # enable-thread-safety is now the default
119 ## if ($row->{branch} eq 'HEAD' || $row->{branch} gt 'REL8_5_STABLE')
121 ## $row->{build_flags} .= " --enable-thread-safety "
122 ## unless ($row->{build_flags} =~ /--(en|dis)able-thread-safety/);
124 $row->{build_flags} =~ s/--((enable|with)-)?//g;
125 $row->{build_flags} =~ s/libxml/xml/;
126 $row->{build_flags} =~ s/\S+=\S+//g;
127 push(@$statrows,$row);
135 my $template_opts = { INCLUDE_PATH => $template_dir };
136 my $template = new Template($template_opts);
138 print "Content-Type: text/html\n\n";
140 $template->process('fstatus.tt',
141 {statrows=>$statrows,
143 max_days => $max_days,
144 all_branches => $all_branches,
145 all_members => $all_members,
146 all_stages => $all_stages,
147 qmembers=> \@members,
148 qbranches => \@branches,
149 qstages => \@stages} );