]> pd.if.org Git - newsd/blob - convactive
Let database figure out close time for connection.
[newsd] / convactive
1 #!/usr/bin/perl
2
3 use strict;
4 use warnings;
5
6 use DBI;
7
8 # TODO cmd line option to actually delete the groups
9
10 # TODO use LWP::UserAgent to fetch a file and load it
11
12 $\="\n";
13 my $db = DBI->connect(undef,undef,undef,{RaiseError=>1,AutoCommit=>0});
14
15 $db->do('create temp table newnewsgroups (like newsgroups including defaults)');
16 $db->do('create index newnewsgroups_idx on newnewsgroups(newsgroup)');
17
18 my $i = $db->prepare('insert into newnewsgroups (newsgroup,posting,creator) values (?,?,?)');
19 my $rmgroup = $db->prepare('update newsgroups N set active = false where local != true and not exists (select newsgroup from newnewsgroups where newsgroup = N.newsgroup)');
20 my $newgroup = $db->prepare('insert into newsgroups select * from newnewsgroups N where not exists (select 1 from newsgroups where newsgroup = N.newsgroup)');
21
22 while (<>) {
23         chomp;
24         my ($group, undef, undef, $mod) = split(/\s+/, $_);
25         $i->execute($group,$mod,'iscactivefile');
26 }
27 $rmgroup->execute();
28 $newgroup->execute();
29
30 $db->commit;
31
32 __END__
33 aaa.inu-chan 0000000000 0000000001 m
34 ab.arnet 0000000000 0000000001 m
35 ab.general 0000000000 0000000001 y
36 ab.jobs 0000000000 0000000001 y
37 ab.politics 0000000000 0000000001 y
38 abg.allgemein 0000000000 0000000001 y
39 abg.amiga 0000000000 0000000001 y
40 abg.comp 0000000000 0000000001 y
41 abg.diskussion 0000000000 0000000001 y
42 abg.english 0000000000 0000000001 y