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 $sort_by);
18 require "$ENV{BFConfDir}/BuildFarmWeb.pl";
19 #require "BuildFarmWeb.pl";
22 my %sort_ok = ('name' => 'lower(name)' ,
23 'owner' => 'lower(owner_email)',
24 'os' => 'lower(operating_system), os_version',
25 'compiler' => 'lower(compiler), compiler_version' ,
26 'arch' => 'lower(architecture)' );
27 $sort_by = $query->param('sort_by');$sort_by =~ s/[^a-zA-Z0-9_ -]//g;
28 $sort_by = $sort_ok{$sort_by} || $sort_ok{name};
30 my $dsn="dbi:Pg:dbname=$dbname";
31 $dsn .= ";host=$dbhost" if $dbhost;
32 $dsn .= ";port=$dbport" if $dbport;
34 my $db = DBI->connect($dsn,$dbuser,$dbpass,{pg_expand_array => 0});
36 # there is possibly some redundancy in this query, but it makes
37 # a lot of the processing simpler.
41 select name, operating_system, os_version, compiler, compiler_version, owner_email,
42 sys_notes_ts::date AS sys_notes_date, sys_notes,
43 architecture as arch, ARRAY(
44 select branch || ':' ||
45 extract(days from now() - l.snapshot)
46 from latest_snapshot l
47 where l.sysname = s.name
48 order by branch <> 'HEAD', branch desc
50 ARRAY(select compiler_version || '\t' || os_version || '\t' || effective_date
53 order by effective_date
56 where status = 'approved'
59 $statement .= "order by $sort_by";
62 my $sth=$db->prepare($statement);
64 while (my $row = $sth->fetchrow_hashref)
66 $row->{branches} =~ s/^\{(.*)\}$/$1/;
67 my $personalities = $row->{personalities};
68 $personalities =~ s/^\{(.*)\}$/$1/;
69 my @personalities = split(',',$personalities);
70 $row->{personalities} = [];
71 foreach my $personality (@personalities)
73 $personality =~ s/^"(.*)"$/$1/;
74 $personality =~ s/\\(.)/$1/g;
76 my ($compiler_version, $os_version, $effective_date) = split(/\t/,$personality);
77 $effective_date =~ s/ .*//;
78 push(@{$row->{personalities}}, {compiler_version => $compiler_version,
79 os_version => $os_version,
80 effective_date => $effective_date });
82 $row->{owner_email} =~ s/\@/ [ a t ] /;
83 push(@$statrows,$row);
90 # use Data::Dumper; print "Content-Type: text/plain\n\n",Dumper($statrows),"VERSION: ",$DBD::Pg::VERSION,"\n"; exit;
93 my $template_opts = { INCLUDE_PATH => $template_dir};
94 my $template = new Template($template_opts);
96 print "Content-Type: text/html\n\n";
98 $template->process('members.tt',
99 {statrows=>$statrows});