5 Copyright (c) 2003-2010, Andrew Dunstan
6 Copyright (c) 2022, The Exim Maintainers
8 See accompanying License file for license details
17 use vars qw($dbhost $dbname $dbuser $dbpass $dbport $template_dir);
19 use FindBin qw($RealBin);
20 require "$RealBin/../BuildFarmWeb.pl";
22 die "no dbname" unless $dbname;
23 die "no dbuser" unless $dbuser;
25 my $dsn="dbi:Pg:dbname=$dbname";
26 $dsn .= ";host=$dbhost" if $dbhost;
27 $dsn .= ";port=$dbport" if $dbport;
29 my $db = DBI->connect($dsn,$dbuser,$dbpass);
31 die $DBI::errstr unless $db;
34 my $member = $query->param('nm'); $member =~ s/[^a-zA-Z0-9_ -]//g;
35 my $branch = $query->param('br'); $branch =~ s/[^a-zA-Z0-9+_ .-]//g;
36 my $hm = $query->param('hm'); $hm =~ s/[^a-zA-Z0-9_ -]//g;
37 $hm = '240' unless $hm =~ /^\d+$/;
39 my $latest_personality = $db->selectrow_arrayref(q{
40 select os_version, compiler_version
43 order by effective_date desc limit 1
47 select operating_system, os_version, compiler, compiler_version, architecture,
48 owner_email, sys_notes_ts::date AS sys_notes_date, sys_notes
50 where b.status = 'approved'
57 from build_status_recent_500
61 SELECT (now() at time zone 'GMT')::timestamp(0) - x.snapshot as when_ago,
62 x.sysname, x.snapshot, x.status, x.stage, s.log_text, x.git_head_ref
64 LEFT JOIN build_status_log s
65 ON x.snapshot = s.snapshot AND s.log_stage = 'test-results.log'
66 ORDER BY x.snapshot desc
71 my $sth = $db->prepare($systemdata);
72 $sth->execute($member);
73 my $sysrow = $sth->fetchrow_hashref;
75 $sth=$db->prepare($statement);
76 $sth->execute($member,$branch);
77 while (my $row = $sth->fetchrow_hashref)
80 while (my($k,$v) = each %$sysrow) { $row->{$k} = $v; }
81 $row->{owner_email} =~ s/\@/ [ a t ] /;
82 if ($latest_personality)
84 $row->{os_version} = $latest_personality->[0];
85 $row->{compiler_version} = $latest_personality->[1];
88 # convert list of individual testresults to list of ranges of equal results
89 # for speed of display
90 if (defined($row->{log_text}))
91 { # convert to a hash, find ranges, output list of ranges
92 my $h = { split /\s+/, $row->{log_text} };
97 foreach my $k (sort {$a<=>$b} keys %$h)
101 if ($h->{$k} ne $h->{$start})
103 push @ranges, sprintf("%s %s %s", $h->{$start}, $start, $i);
120 push @ranges, sprintf("%s %s %s", $h->{$start}, $start, $i);
123 $row->{log_text} = \@ranges;
126 push(@$statrows,$row);
133 my $template_opts = { INCLUDE_PATH => $template_dir, EVAL_PERL => 1 };
134 my $template = new Template($template_opts);
136 print "Content-Type: text/html\n\n";
138 $template->process('history.tt',
139 {statrows=>$statrows,