Medium sized Internalization made by flattener against megalog-2017-11-01
[andk-cpan-tools.git] / bin / report-missing-reports.pl
blobbc5f97b4c1d15951474eb738a6b17302cfa5167c
1 #!/usr/bin/perl
3 # use 5.010;
4 use strict;
5 use warnings;
7 =head1 NAME
11 =head1 SYNOPSIS
15 =head1 OPTIONS
17 =over 8
19 =cut
21 my @opt = <<'=back' =~ /B<--(\S+)>/g;
23 =item B<--help|h!>
25 This help
27 =back
29 =head1 DESCRIPTION
31 This script is intended to be run once a day. It is a wrapper around
32 refill-cpanstatsdb-minutes.pl which finds missing reports in the
33 cpanstatsdb.
35 =cut
38 use FindBin;
39 use lib "$FindBin::Bin/../lib";
40 BEGIN {
41 push @INC, qw( );
44 use Dumpvalue;
45 use File::Basename qw(dirname);
46 use File::Path qw(mkpath);
47 use File::Spec;
48 use File::Temp;
49 use Getopt::Long;
50 use Hash::Util qw(lock_keys);
52 our %Opt;
53 lock_keys %Opt, map { /([^=]+)/ } @opt;
54 GetOptions(\%Opt,
55 @opt,
56 ) or pod2usage(1);
58 use File::Basename ();
59 use File::Path ();
60 use DateTime ();
62 my($root) = "$ENV{HOME}/var/metabase-log/missings";
63 my($refillroot) = "$ENV{HOME}/var/refill-cpanstatsdb";
64 my($prg) = "$ENV{HOME}/src/andk-cpan-tools/bin/refill-cpanstatsdb-minutes.pl";
66 my $dt = DateTime->new( time_zone => 'UTC', year => 2012, month => 10, day => 8);
67 my $dtmax = DateTime->now( time_zone => 'UTC' );
68 $dtmax->subtract(days => 3);
69 while () {
70 my $path = sprintf "%s/%s/%s.rpt", $root, $dt->year, $dt->ymd;
71 if (! -e $path){
72 File::Path::mkpath File::Basename::dirname $path;
73 my $pickdate = $dt->ymd("");
74 my $refillpath = sprintf "%s/%s/%s", $refillroot, $dt->year, $dt->month;
75 my $command = sprintf "%s %s --pickdate=%s --collectguids %s > %s 2> %s.err", $^X, $prg, $pickdate, $refillpath, $path, $path;
76 warn "RUNNING $command\n";
77 0 == system $command or die;
78 for ("$path.err"){
79 unlink $_ unless -s $_;
82 $dt->add( days => 1 );
83 last if $dt > $dtmax;
86 # Local Variables:
87 # mode: cperl
88 # cperl-indent-level: 4
89 # End: