fixed legend to not wrap on element 5, updated footer to thank community
[buildfarm-server.git] / cgi-bin / show_status.pl
1 #!/usr/bin/perl
2
3 use strict;
4 use DBI;
5 use Template;
6 use CGI;
7
8 use vars qw($dbhost $dbname $dbuser $dbpass $dbport);
9
10
11 require "$ENV{BFConfDir}/BuildFarmWeb.pl";
12
13 my $query = new CGI;
14 my @members = $query->param('member');
15 map { s/[^a-zA-Z0-9_ -]//g; } @members;
16
17 my $dsn="dbi:Pg:dbname=$dbname";
18 $dsn .= ";host=$dbhost" if $dbhost;
19 $dsn .= ";port=$dbport" if $dbport;
20
21 my $db = DBI->connect($dsn,$dbuser,$dbpass) or die("$dsn,$dbuser,$dbpass,$!");
22
23 # there is possibly some redundancy in this query, but it makes
24 # a lot of the processing simpler.
25
26 my $statement = <<EOS;
27
28   select (now() at time zone 'GMT')::timestamp(0) - snapshot as when_ago,
29       sysname, snapshot, b.status, stage, branch, build_flags,
30       operating_system, os_version, compiler, compiler_version, architecture 
31   from buildsystems s, 
32        build_status b
33        natural join 
34        (select sysname, branch, max(snapshot) as snapshot
35         from build_status
36         group by sysname, branch
37         having max(snapshot) > now() - '30 days'::interval
38        ) m
39   where name = sysname
40         and s.status = 'approved'
41   order by branch = 'HEAD' desc, 
42         branch desc, 
43         snapshot desc
44
45 EOS
46 ;
47
48 $statement =<<EOS;
49
50
51   select (now() at time zone 'GMT')::timestamp(0) - snapshot as when_ago,
52         sysname, snapshot, b.status, stage, branch, build_flags,
53         operating_system, coalesce(b.os_version,s.os_version) as os_version,
54         compiler, coalesce(b.compiler_version, s.compiler_version) as compiler_version, 
55         architecture 
56   from buildsystems s, 
57         (
58         select distinct on (bs.sysname, bs.branch, bs.report_time) 
59                sysname, snapshot, status, stage, branch, build_flags,
60                report_time ,compiler_version, os_version
61         from build_status bs
62              left join 
63              personality p
64              on (p.name = bs.sysname and p.effective_date <= bs.report_time)
65         order by bs.sysname, bs.branch, bs.report_time, 
66                  p.effective_date is null, p.effective_date desc
67         ) as b
68         natural join 
69         (select sysname, branch, max(snapshot) as snapshot
70         from build_status
71         group by sysname, branch
72         having max(snapshot) > now() - '30 days'::interval
73         ) m
74   where name = sysname
75         and s.status = 'approved'
76   order by branch = 'HEAD' desc,
77         branch desc, 
78         snapshot desc
79
80
81
82 EOS
83 ;
84
85 my $statrows=[];
86 my $sth=$db->prepare($statement);
87 $sth->execute;
88 while (my $row = $sth->fetchrow_hashref)
89 {
90     next if (@members && ! grep {$_ eq $row->{sysname} } @members);
91     $row->{build_flags}  =~ s/^\{(.*)\}$/$1/;
92     $row->{build_flags}  =~ s/,/ /g;
93     $row->{build_flags}  =~ s/--((enable|with)-)?//g;
94     $row->{build_flags}  =~ s/\S+=\S+//g;
95     push(@$statrows,$row);
96 }
97 $sth->finish;
98
99
100 $db->disconnect;
101
102 my $template = new Template({});
103
104 print "Content-Type: text/html\n\n";
105
106 $template->process(\*DATA,{statrows=>$statrows});
107
108 exit;
109
110 =comment
111
112 [%- BLOCK img ; flag ; END -%]
113 [%- BLOCK imgx ; IF flag_imgs.$flag ; '<img src="' . flag_imgs{flag} . '" alt="' . flag . '" /> ' ; ELSE flag . ' ' ; END ; END -%]
114
115 =cut
116
117 __DATA__
118 [%
119  flag_imgs = {
120      perl = '/img/camel.png',
121      python = '/img/python.png',
122      debug = '/img/bug.png',
123      pam => '/img/pam.png',
124      cassert => '/img/cassert.png',
125      openssl => '/img/ssl_icon.gif',
126      nls => '/img/translateicon.gif',
127      krb5 => '/img/krb.gif',
128      tcl => '/img/tcl.png',
129      xml => '/img/xml.png',
130      'thread-safety' => '/img/threads.gif',
131      'integer-datetimes' = '/img/days.png',
132      }
133 -%]
134 [%- BLOCK img ; IF flag == 'depend' or flag == 'gnu-ld' ; ; ELSIF flag_imgs.$flag %]<img src="[% flag_imgs.$flag %]" title="[% flag %]" alt="[% flag %]" height="16" width="16" class="inline" align="bottom" />  [% ELSE %][%#
135                                                                                                                                                                                                           flag ; ' '
136 %][% END ; END -%]
137 [%- BLOCK cl %] class=" [% SWITCH bgfor -%]
138   [%- CASE 'OK' %]pass[% CASE 'ContribCheck' %]warn[% CASE [ 'Check' 'InstallCheck' ] %]warnx[% CASE %]fail[% END %]"
139 [%- END -%]
140 <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
141         "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
142 <html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
143 <head>
144         <meta http-equiv="content-type" content="text/html; charset=utf-8" />
145     <title>PostgreSQL BuildFarm Status</title>
146 <link rel="icon" type="image/png" href="/elephant-icon.png" />  
147     <link rel="stylesheet" rev="stylesheet" href="/inc/pgbf.css" charset="utf-8" />
148         <style type="text/css"><!--
149         li#status a { color:rgb(17,45,137); background: url(/inc/b/r.png) no-repeat 100% -20px; } 
150         li#status { background: url(/inc/b/l.png) no-repeat 0% -20px; }
151         --></style>
152 </head>
153 <body>
154 <div id="wrapper">
155 <div id="banner">
156 <a href="/index.html"><img src="/inc/pgbuildfarm-banner.png" alt="PostgreSQL BuildFarm" width="800" height="73" /></a>
157 <div id="nav">
158 <ul>
159     <li id="home"><a href="/index.html" title="PostgreSQL BuildFarm Home">Home</a></li>
160     <li id="status"><a href="/cgi-bin/show_status.pl" title="Current results">Status</a></li>
161     <li id="members"><a href="/cgi-bin/show_members.pl" title="Platforms tested">Members</a></li>
162     <li id="register"><a href="/register.html" title="Join PostgreSQL BuildFarm">Register</a></li>
163     <li id="pgfoundry"><a href="http://pgfoundry.org/projects/pgbuildfarm/">PGFoundry</a></li>
164     <li id="postgresql.org"><a href="http://www.postgresql.org">PostgreSQL.org</a></li>
165 </ul>
166 </div><!-- nav -->
167 </div><!-- banner -->
168 <div id="main">
169     <h1>PostgreSQL BuildFarm Status</h1>
170     <p>
171       Shown here is the latest status of each farm member 
172       for each branch it has reported on in the last 30 days.
173     </p>
174     <p>
175        Use the farm member link for history of that member 
176        on the relevant branch.
177     </p>
178 <table><tr><th class="head" rowspan="2">Legend</th>
179 [% FOREACH flagset IN flag_imgs %]
180 <td><img src="[% flagset.value %]" title="[% flagset.key %]" alt="[% flagset.key %]" height="16" width="16" class="inline"  align="center"/> =  [% flagset.key %]</td>
181 [% IF loop.count == 6 %]</tr><tr>[% END %]
182 [% END %]
183 </tr></table>
184 <br />
185     <table cellspacing="0">
186 [% brch = "" %]
187 [% FOREACH row IN statrows %]
188 [% IF row.branch != brch ; brch = row.branch %]
189 <tr><th class="head" colspan="4">Branch: [% brch %]</th></tr>
190 <tr><th>Alias</th><th>System</th><th>Status</th><th>Flags</th></tr>
191 [% END %]
192 <tr [% PROCESS cl bgfor=row.stage %]>
193     <td><a 
194     href="show_history.pl?nm=[% row.sysname %]&amp;br=[% row.branch %]"
195     title="History"
196     >[% row.sysname %]</a></td>
197     <td><span class="opsys">[% row.operating_system %]
198             [% row.os_version %]</span> <span class="compiler">
199             [%- row.compiler %]
200             [% row.compiler_version %]</span> <span class="arch">
201             [%- row.architecture %]</span></td>
202     <td class="status">
203             [%- row.when_ago | replace('\s','&nbsp;') %]&nbsp;ago&nbsp;
204             [% row.stage -%]
205             <a href="show_log.pl?nm=
206                [%- row.sysname %]&amp;dt=
207                [%- row.snapshot | uri %]">
208                 [%- IF row.stage != 'OK' %]Details[% ELSE %]Config[% END -%]</a></td>
209
210     <td class="flags">[% FOREACH flag IN row.build_flags.split().sort() ; PROCESS img ; END %]</td>
211 </tr>
212 [% END %]
213     </table>
214 </div><!-- main -->
215 <hr />
216 <p style="text-align: center;">
217 The PostgreSQL Buildfarm website is provided by: 
218 <a href="http://www.commandprompt.com">CommandPrompt, 
219 The PostgreSQL Company</a> <br />
220 The PostgreSQL community makes it work!
221 </p>
222 </div><!-- wrapper -->
223   </body>
224 </html>
225
226
227
228
229
230
231
232