10 use vars qw($dbhost $dbname $dbuser $dbpass $dbport $template_dir $sort_by);
13 require "$ENV{BFConfDir}/BuildFarmWeb.pl";
14 #require "BuildFarmWeb.pl";
17 my %sort_ok = ('name' => 'lower(name)' ,
18 'owner' => 'lower(owner_email)',
19 'os' => 'lower(operating_system), os_version',
20 'compiler' => 'lower(compiler), compiler_version' ,
21 'arch' => 'lower(architecture)' );
22 $sort_by = $query->param('sort_by');$sort_by =~ s/[^a-zA-Z0-9_ -]//g;
23 $sort_by = $sort_ok{$sort_by} || $sort_ok{name};
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 # there is possibly some redundancy in this query, but it makes
32 # a lot of the processing simpler.
36 select name, operating_system, os_version, compiler, compiler_version, owner_email,
37 sys_notes_ts::date AS sys_notes_date, sys_notes,
38 architecture as arch, ARRAY(
39 select branch || ':' ||
40 extract(days from now() - l.snapshot)
41 from latest_snapshot l
42 where l.sysname = s.name
43 order by branch <> 'HEAD', branch desc
45 ARRAY(select compiler_version || '\t' || os_version || '\t' || effective_date
48 order by effective_date
51 where status = 'approved'
54 $statement .= "order by $sort_by";
57 my $sth=$db->prepare($statement);
59 while (my $row = $sth->fetchrow_hashref)
61 $row->{branches} =~ s/^\{(.*)\}$/$1/;
62 my $personalities = $row->{personalities};
63 $personalities =~ s/^\{(.*)\}$/$1/;
64 my @personalities = split(',',$personalities);
65 $row->{personalities} = [];
66 foreach my $personality (@personalities)
68 $personality =~ s/^"(.*)"$/$1/;
69 $personality =~ s/\\(.)/$1/g;
71 my ($compiler_version, $os_version, $effective_date) = split(/\t/,$personality);
72 $effective_date =~ s/ .*//;
73 push(@{$row->{personalities}}, {compiler_version => $compiler_version,
74 os_version => $os_version,
75 effective_date => $effective_date });
77 $row->{owner_email} =~ s/\@/ [ a t ] /;
78 push(@$statrows,$row);
85 # use Data::Dumper; print "Content-Type: text/plain\n\n",Dumper($statrows),"VERSION: ",$DBD::Pg::VERSION,"\n"; exit;
88 my $template_opts = { INCLUDE_PATH => $template_dir};
89 my $template = new Template($template_opts);
91 print "Content-Type: text/html\n\n";
93 $template->process('members.tt',
94 {statrows=>$statrows});