bozo filter
[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 $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 distinct on (branch <> 'HEAD', branch) 
39                                        branch || ':' || 
40                                        extract(days from now() - snapshot)
41                                 from build_status 
42                                 where name = sysname
43                                 order by branch <> 'HEAD', branch desc, 
44                                          snapshot desc
45                                 ) as branches 
46   from buildsystems 
47   where status = 'approved'
48   order by $sort_by
49
50 EOS
51 ;
52
53 my $statrows=[];
54 my $sth=$db->prepare($statement);
55 $sth->execute;
56 while (my $row = $sth->fetchrow_hashref)
57 {
58     $row->{branches} =~ s/^\{(.*)\}$/$1/;
59     $row->{owner_email} =~ s/\@/ [ a t ] /;
60     push(@$statrows,$row);
61 }
62 $sth->finish;
63
64
65 $db->disconnect;
66
67 # use Data::Dumper; print "Content-Type: text/plain\n\n",Dumper($statrows),"VERSION: ",$DBD::Pg::VERSION,"\n"; exit;
68
69
70 my $template = new Template({});
71
72 print "Content-Type: text/html\n\n";
73
74 $template->process(\*DATA,{statrows=>$statrows});
75
76 exit;
77
78
79 __DATA__
80 <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
81         "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
82 <html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
83 <head>
84         <meta http-equiv="content-type" content="text/html; charset=utf-8" />
85         <title>PostgreSQL BuildFarm Members</title>
86         <link rel="icon" type="image/png" href="/elephant-icon.png" />
87         <link rel="stylesheet" rev="stylesheet" href="/inc/pgbf.css" charset="utf-8" />
88         <style type="text/css"><!--
89         li#members a { color:rgb(17,45,137); background: url(/inc/b/r.png) no-repeat 100% -20px; } 
90         li#members { background: url(/inc/b/l.png) no-repeat 0% -20px; }
91         --></style>
92    </style>
93 </head>
94 <body class="members">
95 <div id="wrapper">
96 <div id="banner">
97 <a href="/index.html"><img src="/inc/pgbuildfarm-banner.png" alt="PostgreSQL BuildFarm" width="800" height="73" /></a>
98 <div id="nav">
99 <ul>
100     <li id="home"><a href="/index.html" title="PostgreSQL BuildFarm Home">Home</a></li>
101     <li id="status"><a href="/cgi-bin/show_status.pl" title="Current results">Status</a></li>
102     <li id="members"><a href="/cgi-bin/show_members.pl" title="Platforms tested">Members</a></li>
103     <li id="register"><a href="/register.html" title="Join PostgreSQL BuildFarm">Register</a></li>
104     <li id="pgfoundry"><a href="http://pgfoundry.org/projects/pgbuildfarm/">PGFoundry</a></li>
105 </ul>
106 </div><!-- nav -->
107 </div><!-- banner -->
108 <div id="main">
109 <h1>PostgreSQL BuildFarm Members</h1>
110     <p>Click branch links to see build history. Click the heading links to resort the list. Select members by checkbox and hit the button at the bottom to create a status custom filter.</p>
111     <form name="filter" method="GET" action="/cgi-bin/show_status.pl">
112     <table cellspacing="0">
113     <tr>
114     <td>&nbsp;</td>
115     <th><a href="/cgi-bin/show_members.pl?sort_by=name">Name</a><br /><a href="/cgi-bin/show_members.pl?sort_by=owner">Owner</a></th>
116     <th><a href="/cgi-bin/show_members.pl?sort_by=os">OS / Version</a></th>
117     <th><a href="/cgi-bin/show_members.pl?sort_by=compiler">Compiler / Version</a></th>
118     <th><a href="/cgi-bin/show_members.pl?sort_by=arch">Arch</a></th>
119     <th>Branches reported on<br />(most recent report)</th>
120     </tr>
121 [% alt = true %]
122 [% FOREACH row IN statrows %]    <tr [%- IF alt %]class="alt"[% END -%]>
123     [% alt = ! alt %]
124     <td><input type="checkbox" name="member" value="[% row.name %]" /></td>
125     <td>[% row.name %]<br />[% row.owner_email %]</td>
126     <td>[% row.operating_system %]<br />[% row.os_version %]</td>
127     <td>[% row.compiler %]<br />[% row.compiler_version %]</td>
128     <td>[% row.arch %]</td>
129     <td class="branch">[% IF ! row.branches ; '&nbsp;' ; END -%]
130     <ul>
131     [%- 
132        FOREACH branch_days IN row.branches.split(',') ;
133        branch_fields = branch_days.split(':');
134        branch = branch_fields.0;
135        branch_day = branch_fields.1;
136     %]<li><a 
137     href="show_history.pl?nm=[% row.name %]&amp;br=[% branch %]"
138     title="History"
139     >[% branch %]</a>&nbsp;([% branch_day %]&nbsp;days&nbsp;ago)</li>[% END %]</ul></td>
140     </tr>
141 [% END %]
142     </table>
143     <input type="submit" value="Make Filter" />
144     </form>
145     </div><!-- main -->
146 <hr />
147 <p style="text-align: center;">
148 Hosting for the PostgreSQL Buildfarm is generously 
149 provided by: 
150 <a href="http://www.commandprompt.com">CommandPrompt, 
151 The PostgreSQL Company</a>
152 </p>
153     </div><!-- wrapper -->
154   </body>
155 </html>
156
157
158
159
160
161
162
163