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->multi_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.sysname = s.sysname
56 AND b.snapshot = s.snapshot
57 AND s.log_stage = 'test-results.log'
58 ORDER BY b.branch = 'master' desc,
59 b.branch desc, $sort_clause
66 my $sth=$db->prepare($statement);
69 # walk the set of result rows from the SQL query above
70 while (my $row = $sth->fetchrow_hashref)
72 next if (@members && ! grep {$_ eq $row->{sysname} } @members);
74 $row->{build_flags} =~ s/^\{(.*)\}$/$1/;
75 $row->{build_flags} =~ s/,/ /g;
76 $row->{build_flags} =~ s/_PC\b//g;
77 $row->{build_flags} = lc($row->{build_flags});
79 if (defined($row->{log_text}))
80 { # convert to a hash, find ranges, output list of ranges
81 my $h = { split /\s+/, $row->{log_text} };
82 my ($i, $start, $last);
85 foreach my $k (sort {$a<=>$b} keys %$h)
89 if ($h->{$k} ne $h->{$start} || $k != $last + 1)
91 # The result (skiped, Passed, Failed) for this testcase number
92 # is different to the start one of the range,
93 # or the range became non-contiguous.
94 # Add text for the range to list of ranges
95 # (these three elements get used by "status.tt" BLOCK colourbar)
96 # Reset the start and the count, for a new range.
98 push @ranges, sprintf("%s %s %s", $h->{$start}, $start, $i);
104 # bump the size of this range
110 # First ever range for this row
118 # close out the final range
119 push @ranges, sprintf("%s %s %s", $h->{$start}, $start, $i);
122 $row->{log_text} = \@ranges;
124 push(@$statrows,$row);
132 my $template_opts = { INCLUDE_PATH => $template_dir };
133 my $template = new Template($template_opts);
135 print "Content-Type: text/html\n\n";
137 $template->process('status.tt',
138 {statrows=>$statrows});