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);
19 require "$ENV{BFConfDir}/BuildFarmWeb.pl";
20 #require "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
46 # we don't really need to do this join, since we only want
47 # one row from buildsystems. but it means we only have to run one
48 # query. If it gets heavy we'll split it up and run two
50 my $statement = <<EOS;
52 select (now() at time zone 'GMT')::timestamp(0) - snapshot as when_ago,
53 sysname, snapshot, b.status, stage,
54 operating_system, os_version, compiler, compiler_version, architecture,
56 sys_notes_ts::date AS sys_notes_date, sys_notes
61 and s.status = 'approved'
63 order by snapshot desc
70 my $sth=$db->prepare($statement);
71 $sth->execute($member,$branch);
72 while (my $row = $sth->fetchrow_hashref)
74 $row->{owner_email} =~ s/\@/ [ a t ] /;
75 if ($latest_personality)
77 $row->{os_version} = $latest_personality->[0];
78 $row->{compiler_version} = $latest_personality->[1];
80 push(@$statrows,$row);
87 my $template_opts = { INCLUDE_PATH => $template_dir, EVAL_PERL => 1 };
88 my $template = new Template($template_opts);
90 print "Content-Type: text/html\n\n";
92 $template->process('history.tt',