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";
21 die "no dbname" unless $dbname;
22 die "no dbuser" unless $dbuser;
24 my $dsn="dbi:Pg:dbname=$dbname";
25 $dsn .= ";host=$dbhost" if $dbhost;
26 $dsn .= ";port=$dbport" if $dbport;
28 my $db = DBI->connect($dsn,$dbuser,$dbpass);
30 die $DBI::errstr unless $db;
33 my $member = $query->param('nm'); $member =~ s/[^a-zA-Z0-9_ -]//g;
34 my $branch = $query->param('br'); $branch =~ s/[^a-zA-Z0-9_ -]//g;
35 my $hm = $query->param('hm'); $hm =~ s/[^a-zA-Z0-9_ -]//g;
36 $hm = '240' unless $hm =~ /^\d+$/;
38 my $latest_personality = $db->selectrow_arrayref(q{
39 select os_version, compiler_version
42 order by effective_date desc limit 1
46 select operating_system, os_version, compiler, compiler_version, architecture,
47 owner_email, sys_notes_ts::date AS sys_notes_date, sys_notes
49 where b.status = 'approved'
56 from build_status_recent_500
60 SELECT (now() at time zone 'GMT')::timestamp(0) - x.snapshot as when_ago,
61 x.sysname, x.snapshot, x.status, x.stage, s.log_text
63 LEFT JOIN build_status_log s
64 ON x.snapshot = s.snapshot AND s.log_stage = 'test-results.log'
65 ORDER BY x.snapshot desc
70 my $sth = $db->prepare($systemdata);
71 $sth->execute($member);
72 my $sysrow = $sth->fetchrow_hashref;
74 $sth=$db->prepare($statement);
75 $sth->execute($member,$branch);
76 while (my $row = $sth->fetchrow_hashref)
79 while (my($k,$v) = each %$sysrow) { $row->{$k} = $v; }
80 $row->{owner_email} =~ s/\@/ [ a t ] /;
81 if ($latest_personality)
83 $row->{os_version} = $latest_personality->[0];
84 $row->{compiler_version} = $latest_personality->[1];
86 if (defined($row->{log_text}))
87 { # convert to a hash, find ranges, output list of ranges
88 my $h = { split /\s+/, $row->{log_text} };
93 foreach my $k (sort {$a<=>$b} keys %$h)
97 if ($h->{$k} ne $h->{$start})
99 push @ranges, sprintf("%s %s %s", $h->{$start}, $start, $i);
116 push @ranges, sprintf("%s %s %s", $h->{$start}, $start, $i);
119 $row->{log_text} = \@ranges;
122 push(@$statrows,$row);
129 my $template_opts = { INCLUDE_PATH => $template_dir, EVAL_PERL => 1 };
130 my $template = new Template($template_opts);
132 print "Content-Type: text/html\n\n";
134 $template->process('history.tt',
135 {statrows=>$statrows,