Skip to content

Commit

Permalink
script/contributor: added flag 'age' + debug logging
Browse files Browse the repository at this point in the history
added the flag: --age N to update releases with value of
the 'date' field in the last N days.

added debug level logging of release names.
  • Loading branch information
mickeyn committed May 24, 2017
1 parent 96aeab1 commit 272fcc6
Showing 1 changed file with 12 additions and 1 deletion.
13 changes: 12 additions & 1 deletion lib/MetaCPAN/Script/Contributor.pm
Expand Up @@ -4,9 +4,11 @@ use strict;
use warnings;

use Moose;

use Log::Contextual qw( :log );
use Ref::Util qw( is_arrayref );

use MetaCPAN::Types qw( Bool HashRef Str );
use MetaCPAN::Types qw( Bool HashRef Int Str );

with 'MetaCPAN::Role::Script', 'MooseX::Getopt',
'MetaCPAN::Script::Role::Contributor';
Expand All @@ -32,6 +34,12 @@ has release => (
'update contributors for a single release (format: author/release_name)',
);

has age => (
is => 'ro',
isa => Int,
documentation => 'update contributors for a given number of days back',
);

has author_release => (
is => 'ro',
isa => HashRef,
Expand Down Expand Up @@ -67,6 +75,8 @@ sub run {
]
}
}
: $self->age
? { range => { date => { gte => sprintf( 'now-%dd', $self->age ) } } }
: return;

my $timeout = $self->all ? '60m' : '5m';
Expand All @@ -89,6 +99,7 @@ sub run {
$r->{fields}{distribution}[0],
);
next unless is_arrayref($contrib_data);
log_debug { 'adding release ' . $r->{fields}{name}[0] };
push @data => @{$contrib_data};
}

Expand Down

0 comments on commit 272fcc6

Please sign in to comment.