6 use Debbugs::Config qw(:globals);
8 use Debbugs::Bugs qw(count_bugs);
9 use Debbugs::Status qw(get_bug_status);
14 die "failed to get time: $!" unless defined $startdate;
16 # check the ctime of '/org/bugs.debian.org/www/stats/bugclosers.txt'
18 my $ob = stat '/org/bugs.debian.org/www/stats/bugclosers.txt';
19 if (defined $ob and (time - $ob->ctime) < 60*60*12) {
20 # If less than 12 hours have passed since we last ran this file,
26 my %bugclosers = count_bugs(function => sub {
28 return () unless $d{status} eq 'done';
30 my $status = get_bug_status(bug => $d{bug});
31 return () unless %$status;
32 my @merged = sort split ' ', $status->{mergedwith};
33 return () if @merged and $merged[0] < $d{bug};
35 return ($status->{done});
38 open BUGCLOSERS, '> /org/bugs.debian.org/www/stats/bugclosers.txt.new'
39 or die "can't open bugclosers.txt.new: $!";
40 binmode(BUGCLOSERS,':raw:encoding(UTF-8)');
41 for my $closer (sort { $bugclosers{$a} <=> $bugclosers{$b} } keys %bugclosers) {
42 printf BUGCLOSERS "%4d %s\n", $bugclosers{$closer}, $closer
43 or die "can't write to bugclosers.txt.new: $!";
45 close BUGCLOSERS or die "can't close bugclosers.txt.new: $!";
46 rename '/org/bugs.debian.org/www/stats/bugclosers.txt.new',
47 '/org/bugs.debian.org/www/stats/bugclosers.txt'
48 or die "can't rename bugclosers.txt.new to bugclosers.txt: $!";