remove redundant file
[buildfarm-server.git] / cgi-bin / show_members.pl
1 #!/usr/bin/perl
2
3 use strict;
4 use CGI;
5 use DBI;
6 use Template;
7
8
9
10 use vars qw($dbhost $dbname $dbuser $dbpass $dbport $template_dir $sort_by);
11
12
13 require "$ENV{BFConfDir}/BuildFarmWeb.pl";
14 #require "BuildFarmWeb.pl";
15
16 my $query = new CGI;
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};
24
25 my $dsn="dbi:Pg:dbname=$dbname";
26 $dsn .= ";host=$dbhost" if $dbhost;
27 $dsn .= ";port=$dbport" if $dbport;
28
29 my $db = DBI->connect($dsn,$dbuser,$dbpass);
30
31 # there is possibly some redundancy in this query, but it makes
32 # a lot of the processing simpler.
33
34 my $statement = <<EOS;
35
36   select name, operating_system, os_version, compiler, compiler_version, owner_email, 
37     architecture as arch, ARRAY(
38                                 select branch || ':' || 
39                                        extract(days from now() - latest_snapshot)
40                                 from build_status_latest l 
41                                 where l.sysname = s.name
42                                 order by branch <> 'HEAD', branch desc 
43                                 ) as branches 
44   from buildsystems s
45   where status = 'approved'
46   order by $sort_by
47
48 EOS
49 ;
50
51 my $statrows=[];
52 my $sth=$db->prepare($statement);
53 $sth->execute;
54 while (my $row = $sth->fetchrow_hashref)
55 {
56     $row->{branches} =~ s/^\{(.*)\}$/$1/;
57     $row->{owner_email} =~ s/\@/ [ a t ] /;
58     push(@$statrows,$row);
59 }
60 $sth->finish;
61
62
63 $db->disconnect;
64
65 # use Data::Dumper; print "Content-Type: text/plain\n\n",Dumper($statrows),"VERSION: ",$DBD::Pg::VERSION,"\n"; exit;
66
67
68 my $template_opts = { INCLUDE_PATH => $template_dir};
69 my $template = new Template($template_opts);
70
71 print "Content-Type: text/html\n\n";
72
73 $template->process('members.tt',
74                 {statrows=>$statrows});
75
76 exit;
77