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} };
86 foreach my $k (sort {$a<=>$b} keys %$h)
90 if ($h->{$k} ne $h->{$start})
92 # The result (skiped, Passed, Failed) for this testcase number
93 # is different to the start one of the range. Reset the
94 # start and the count, for a new range.
95 push @ranges, sprintf("%s %s %s", $h->{$start}, $start, $i);
101 # bump the size of this range
107 # First ever range for this row
114 # add text for the range to list of ranges
115 push @ranges, sprintf("%s %s %s", $h->{$start}, $start, $i);
118 $row->{log_text} = \@ranges;
120 push(@$statrows,$row);
128 my $template_opts = { INCLUDE_PATH => $template_dir };
129 my $template = new Template($template_opts);
131 print "Content-Type: text/html\n\n";
133 $template->process('status.tt',
134 {statrows=>$statrows});