8 use vars qw($dbhost $dbname $dbuser $dbpass $dbport
11 use FindBin qw($RealBin);
12 require "$RealBin/../BuildFarmWeb.pl";
14 die "no dbname" unless $dbname;
15 die "no dbuser" unless $dbuser;
17 my $dsn="dbi:Pg:dbname=$dbname";
18 $dsn .= ";host=$dbhost" if $dbhost;
19 $dsn .= ";port=$dbport" if $dbport;
21 my $db = DBI->connect($dsn,$dbuser,$dbpass);
23 die $DBI::errstr unless $db;
25 my ($brhandle,@branches_of_interest);
26 if (open($brhandle,"$RealBin/../htdocs/branches_of_interest.txt"))
28 @branches_of_interest = <$brhandle>;
30 chomp(@branches_of_interest);
33 my $sth = $db->prepare(q[
34 SELECT DISTINCT ON (sysname,branch)
36 FROM build_status AS s
37 JOIN buildsystems AS b ON (s.sysname = b.name)
38 ORDER BY sysname, branch ASC
42 my $del_sth = $db->prepare(q[
43 DELETE FROM build_status
47 my $del_dash_sth = $db->prepare(q[
48 DELETE FROM dashboard_mat
52 my $del_snap_sth = $db->prepare(q[
53 DELETE FROM latest_snapshot
57 while (my $row = $sth->fetchrow_hashref)
59 my $sysname = $row->{sysname};
60 my $branch = $row->{branch};
61 print "Considering $sysname:$branch\n";
62 unless (grep {$_ eq $branch} @branches_of_interest)
64 print "** Delete branch $branch\n";
65 $del_sth->execute($sysname,$branch);
66 $del_dash_sth->execute($sysname,$branch);
67 $del_snap_sth->execute($sysname,$branch);