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);
19 require "$ENV{BFConfDir}/BuildFarmWeb.pl";
22 my @members = $query->param('member');
23 map { s/[^a-zA-Z0-9_ -]//g; } @members;
24 my $max_days = $query->param('max_days') + 0 || 10;
26 my $dsn="dbi:Pg:dbname=$dbname";
27 $dsn .= ";host=$dbhost" if $dbhost;
28 $dsn .= ";port=$dbport" if $dbport;
32 my $presort_clause = "";
33 my $sortby = $query->param('sortby') || 'nosort';
34 if ($sortby eq 'name')
36 $sort_clause = 'lower(b.sysname),';
38 elsif ($sortby eq 'namenobranch')
40 $presort_clause = "lower(b.sysname), b.snapshot desc,"
43 my $db = DBI->connect($dsn,$dbuser,$dbpass,{pg_expand_array => 0})
44 or die("$dsn,$dbuser,$dbpass,$!");
49 select timezone('GMT'::text,
50 now())::timestamp(0) without time zone - b.snapshot AS when_ago,
52 d.stage as current_stage
53 from nrecent_failures_db_data b
54 left join dashboard_mat d
55 on (d.sysname = b.sysname and d.branch = b.branch)
56 where (now()::timestamp(0) without time zone - b.snapshot) < (? * interval '1 day')
57 order by $presort_clause
58 b.branch = 'HEAD' desc,
67 my $sth=$db->prepare($statement);
68 $sth->execute($max_days);
69 while (my $row = $sth->fetchrow_hashref)
71 next if (@members && ! grep {$_ eq $row->{sysname} } @members);
72 $row->{build_flags} =~ s/^\{(.*)\}$/$1/;
73 $row->{build_flags} =~ s/,/ /g;
74 # enable-integer-datetimes is now the default
75 if ($row->{branch} eq 'HEAD' || $row->{branch} gt 'REL8_3_STABLE')
77 $row->{build_flags} .= " --enable-integer-datetimes "
78 unless ($row->{build_flags} =~ /--(en|dis)able-integer-datetimes/);
80 # enable-thread-safety is now the default
81 if ($row->{branch} eq 'HEAD' || $row->{branch} gt 'REL8_5_STABLE')
83 $row->{build_flags} .= " --enable-thread-safety "
84 unless ($row->{build_flags} =~ /--(en|dis)able-thread-safety/);
86 $row->{build_flags} =~ s/--((enable|with)-)?//g;
87 $row->{build_flags} =~ s/libxml/xml/;
88 $row->{build_flags} =~ s/\S+=\S+//g;
89 push(@$statrows,$row);
97 my $template_opts = { INCLUDE_PATH => $template_dir };
98 my $template = new Template($template_opts);
100 print "Content-Type: text/html\n\n";
102 $template->process('fstatus.tt',
103 {statrows=>$statrows,
105 max_days => $max_days,
106 members=> \@members} );