8 use vars qw($dbhost $dbname $dbuser $dbpass $dbport
10 require "$ENV{BFConfDir}/BuildFarmWeb.pl";
12 die "no dbname" unless $dbname;
13 die "no dbuser" unless $dbuser;
15 my $dsn="dbi:Pg:dbname=$dbname";
16 $dsn .= ";host=$dbhost" if $dbhost;
17 $dsn .= ";port=$dbport" if $dbport;
19 my $db = DBI->connect($dsn,$dbuser,$dbpass);
21 die $DBI::errstr unless $db;
23 my ($brhandle,@branches_of_interest);
24 if (open($brhandle,"$ENV{BFConfDir}/htdocs/branches_of_interest.txt"))
26 @branches_of_interest = <$brhandle>;
28 chomp(@branches_of_interest);
31 my $sth = $db->prepare(q[
32 SELECT DISTINCT ON (sysname,branch)
34 FROM build_status AS s
35 JOIN buildsystems AS b ON (s.sysname = b.name)
36 ORDER BY sysname, branch ASC
40 my $del_sth = $db->prepare(q[
41 DELETE FROM build_status
45 my $del_dash_sth = $db->prepare(q[
46 DELETE FROM dashboard_mat
50 my $del_snap_sth = $db->prepare(q[
51 DELETE FROM latest_snapshot
55 while (my $row = $sth->fetchrow_hashref)
57 my $sysname = $row->{sysname};
58 my $branch = $row->{branch};
59 print "Considering $sysname:$branch\n";
60 unless (grep {$_ eq $branch} @branches_of_interest)
62 print "** Delete branch $branch\n";
63 $del_sth->execute($sysname,$branch);
64 $del_dash_sth->execute($sysname,$branch);
65 $del_snap_sth->execute($sysname,$branch);