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 = $query->param('member');
23 map { s/[^a-zA-Z0-9_ -]//g; } @members;
25 my $dsn="dbi:Pg:dbname=$dbname";
26 $dsn .= ";host=$dbhost" if $dbhost;
27 $dsn .= ";port=$dbport" if $dbport;
31 my $sortby = $query->param('sortby') || 'nosort';
32 if ($sortby eq 'name')
34 $sort_clause = 'lower(sysname),';
36 elsif ($sortby eq 'os')
38 $sort_clause = 'lower(operating_system), os_version desc,';
40 elsif ($sortby eq 'compiler')
42 $sort_clause = "lower(compiler), compiler_version,";
45 my $db = DBI->connect($dsn,$dbuser,$dbpass,{pg_expand_array => 0})
46 or die("$dsn,$dbuser,$dbpass,$!");
51 SELECT timezone('GMT'::text, now())::timestamp(0) without time zone - b.snapshot AS when_ago,
54 FROM dashboard_mat b LEFT JOIN build_status_log s
55 ON b.snapshot = s.snapshot AND s.log_stage = 'test-results.log'
56 ORDER BY b.branch = 'master' desc,
57 b.branch desc, $sort_clause
64 my $sth=$db->prepare($statement);
66 while (my $row = $sth->fetchrow_hashref)
68 next if (@members && ! grep {$_ eq $row->{sysname} } @members);
69 $row->{build_flags} =~ s/^\{(.*)\}$/$1/;
70 $row->{build_flags} =~ s/,/ /g;
71 $row->{build_flags} =~ s/_PC\b//g;
72 $row->{build_flags} = lc($row->{build_flags});
73 if (defined($row->{log_text}))
74 { # convert to a hash, find ranges, output list of ranges
75 my $h = { split /\s+/, $row->{log_text} };
80 foreach my $k (sort {$a<=>$b} keys %$h)
84 if ($h->{$k} ne $h->{$start})
86 push @ranges, sprintf("%s %s %s", $h->{$start}, $start, $i);
103 push @ranges, sprintf("%s %s %s", $h->{$start}, $start, $i);
106 $row->{log_text} = \@ranges;
108 push(@$statrows,$row);
116 my $template_opts = { INCLUDE_PATH => $template_dir };
117 my $template = new Template($template_opts);
119 print "Content-Type: text/html\n\n";
121 $template->process('status.tt',
122 {statrows=>$statrows});