add another idiot to the filter
[buildfarm-server.git] / cgi-bin / typedefs.pl
1 #!/usr/bin/perl
2
3 use strict;
4 use DBI;
5 use CGI;
6
7 my $query = new CGI;
8
9 use vars qw($dbhost $dbname $dbuser $dbpass $dbport);
10
11 require "$ENV{BFConfDir}/BuildFarmWeb.pl";
12
13 my $dsn="dbi:Pg:dbname=$dbname";
14 $dsn .= ";host=$dbhost" if $dbhost;
15 $dsn .= ";port=$dbport" if $dbport;
16
17 my $dbh = DBI->connect($dsn,$dbuser,$dbpass) or die("$dsn,$dbuser,$dbpass,$!");
18
19 my %words;
20
21 my $sql = q{
22     select sysname, max(snapshot) as snapshot 
23     from build_status_log 
24     where branch = 'HEAD' and 
25         log_stage = 'typedefs.log' and 
26         snapshot > current_date::timestamp - interval '30 days' 
27     group by sysname
28 };
29 my $builds = $dbh->selectall_arrayref($sql, { Slice => {} });
30
31
32 if ($query->param('show_list'))
33 {
34     print "Content-Type: text/html\n\n",
35     "<head><title>Typedefs URLs</title></head>\n",
36     "<body><h1>Typdefs URLs</h1>\n",
37     "<table border='1'><tr><th>member</th></tr>\n";
38
39     foreach my $build (@$builds)
40     {
41         print "<tr><td><a href='http://www.pgbuildfarm.org/cgi-bin/show_stage_log.pl?nm=$build->{sysname}\&amp;dt=$build->{snapshot}\&amp;stg=typedefs'>$build->{sysname}</a></td></tr>\n";
42     }
43     print "</table></body></html>\n";
44     exit;
45 }
46
47 $sql = q{
48    select log_text
49    from build_status_log
50    where sysname = ?
51      and snapshot = ?
52      and log_stage = 'typedefs.log'
53      and branch = 'HEAD'
54  };
55
56 my $sth = $dbh->prepare($sql);
57
58 foreach my $build (@$builds)
59 {
60     $sth->execute($build->{sysname},$build->{snapshot});
61     my @row = $sth->fetchrow;
62     my @typedefs = split(/\s+/,$row[0]);
63     @words{@typedefs} = 1 x @typedefs;
64 }
65
66 print "Content-Type: text/plain\n\n",
67     join("\n",sort keys %words),
68     "\n";