new ticket from slaven
[andk-cpan-tools.git] / bin / rtdatagaps.pl
blob34b3360be28f8a6a459ddf191e7b3d70a8670d9d
2 # $HeadURL: /local/cpanpm/trunk/bin/query-rt-group-by-requestor.pl $
5 =head1 rtdataholes
7 Read YAML databases and list all missing tickets in the style needed
8 as datainput for the rt-deleter.pl
10 =cut
12 use strict;
13 use warnings;
15 use Getopt::Long;
16 use Set::Integer::Gapfillers;
17 use Set::IntSpan::Fast;
18 use YAML::Syck;
19 $YAML::Syck::ImplicitUnicode = 1;
21 my $yaml_db_file = __FILE__;
22 $yaml_db_file =~ s|[^/]+\.pl$|query-rt-group-by-requestor.yml|;
23 my $Q;
24 if (-e $yaml_db_file) {
25 print "Reading '$yaml_db_file'\n";
26 $Q = YAML::Syck::LoadFile($yaml_db_file);
27 } else {
28 die "Didn't find '$yaml_db_file'";
31 my $D;
32 $yaml_db_file =~ s|[^/]+\.yml$|rt-deleter.yml|;
33 if (-e $yaml_db_file) {
34 print "Reading '$yaml_db_file'\n";
35 $D = YAML::Syck::LoadFile($yaml_db_file);
36 } else {
37 die "Didn't find '$yaml_db_file'";
40 print "Constructing the set\n";
41 my $set = Set::IntSpan::Fast->new();
42 for my $k (keys %{$Q->{tickets}}) {
43 $set->add($k) if keys %{$Q->{tickets}{$k}};
45 for my $k (keys %$D) {
46 $set->add($k);
49 my $fset = $set->as_string;
50 print "$fset\n";
52 print "Constructing the gapfiller\n";
53 my @have = map { if (/-/) {
54 [ split /-/, $_ ]
55 } else {
56 [ $_, $_ ]
57 } } split /,/, $fset;
59 my $sigf = Set::Integer::Gapfillers->new(
60 lower => 1,
61 upper => $have[-1][1],
62 sets => \@have,
64 my $gf = $sigf->gapfillers;
65 for my $i (0..$#$gf) {
66 my $gap = $gf->[$i];
67 if ($gap->[0]==$gap->[1]) {
68 print " $gap->[0]";
69 } else {
70 print " $gap->[0]..$gap->[1]";
73 print "\n";