Check that branch is listed in branches_of_interest.txt
[buildfarm-server.git] / cgi-bin / show_status.pl
1 #!/usr/bin/perl
2
3 =comment
4
5 Copyright (c) 2003-2010, Andrew Dunstan
6
7 See accompanying License file for license details
8
9 =cut 
10
11 use strict;
12 use DBI;
13 use Template;
14 use CGI;
15
16 use vars qw($dbhost $dbname $dbuser $dbpass $dbport $template_dir);
17
18
19 require "$ENV{BFConfDir}/BuildFarmWeb.pl";
20
21 my $query = new CGI;
22 my @members = $query->param('member');
23 map { s/[^a-zA-Z0-9_ -]//g; } @members;
24
25 my $dsn="dbi:Pg:dbname=$dbname";
26 $dsn .= ";host=$dbhost" if $dbhost;
27 $dsn .= ";port=$dbport" if $dbport;
28
29
30 my $sort_clause = "";
31 my $sortby = $query->param('sortby') || 'nosort';
32 if ($sortby eq 'name')
33 {
34         $sort_clause = 'lower(sysname),';
35 }
36 elsif ($sortby eq 'os')
37 {
38         $sort_clause = 'lower(operating_system), os_version desc,'; 
39 }
40 elsif ($sortby eq 'compiler')
41 {
42         $sort_clause = "lower(compiler), compiler_version,";
43 }
44
45 my $db = DBI->connect($dsn,$dbuser,$dbpass,{pg_expand_array => 0}) 
46     or die("$dsn,$dbuser,$dbpass,$!");
47
48 my $statement =<<EOS;
49
50
51   select timezone('GMT'::text, now())::timestamp(0) without time zone - b.snapshot AS when_ago, b.*
52   from dashboard_mat b
53   order by branch = 'HEAD' desc,
54         branch desc, $sort_clause 
55         snapshot desc
56
57 EOS
58 ;
59
60 my $statrows=[];
61 my $sth=$db->prepare($statement);
62 $sth->execute;
63 while (my $row = $sth->fetchrow_hashref)
64 {
65     next if (@members && ! grep {$_ eq $row->{sysname} } @members);
66     $row->{build_flags}  =~ s/^\{(.*)\}$/$1/;
67     $row->{build_flags}  =~ s/,/ /g;
68         # enable-integer-datetimes is now the default
69         if ($row->{branch} eq 'HEAD' || $row->{branch} gt 'REL8_3_STABLE')
70         {
71                 $row->{build_flags} .= " --enable-integer-datetimes "
72                         unless ($row->{build_flags} =~ /--(en|dis)able-integer-datetimes/);
73         }
74         # enable-thread-safety is now the default
75         if ($row->{branch} eq 'HEAD' || $row->{branch} gt 'REL8_5_STABLE')
76         {
77                 $row->{build_flags} .= " --enable-thread-safety "
78                         unless ($row->{build_flags} =~ /--(en|dis)able-thread-safety/);
79         }
80     $row->{build_flags}  =~ s/--((enable|with)-)?//g;
81         $row->{build_flags} =~ s/libxml/xml/;
82     $row->{build_flags}  =~ s/\S+=\S+//g;
83     push(@$statrows,$row);
84 }
85 $sth->finish;
86
87
88 $db->disconnect;
89
90
91 my $template_opts = { INCLUDE_PATH => $template_dir };
92 my $template = new Template($template_opts);
93
94 print "Content-Type: text/html\n\n";
95
96 $template->process('status.tt',
97                 {statrows=>$statrows});
98
99 exit;
100