Skip to content

Commit

Permalink
Merge pull request #456 from CPAN-API/leo/make_scripts_work
Browse files Browse the repository at this point in the history
Leo/make scripts work
  • Loading branch information
oalders committed Apr 21, 2016
2 parents 5f3d4fc + 93ae2cf commit 44fb92d
Show file tree
Hide file tree
Showing 3 changed files with 34 additions and 9 deletions.
1 change: 0 additions & 1 deletion .perlcriticrc
Expand Up @@ -10,7 +10,6 @@ verbose = 11
[-RegularExpressions::RequireDotMatchAnything]
[-RegularExpressions::RequireExtendedFormatting]
[-RegularExpressions::RequireLineBoundaryMatching]
[-ValuesAndExpressions::ProhibitAccessOfPrivateData]
[-ValuesAndExpressions::ProhibitNoisyQuotes]
[-Variables::ProhibitPunctuationVars]
[-Subroutines::ProhibitExplicitReturnUndef]
Expand Down
19 changes: 11 additions & 8 deletions lib/MetaCPAN/Script/Ratings.pm
Expand Up @@ -44,9 +44,14 @@ sub run {
log_debug {'Deleting old CPANRatings'};

$type->filter( { term => { user => 'CPANRatings' } } )->delete;
my $bulk = $self->index->bulk( size => 500 );
my $index = $self->index->name;
my $date = DateTime->now->iso8601;

my $bulk = $self->es->bulk_helper(
index => $self->index->name,
type => 'rating',
max_count => 500,
);

my $date = DateTime->now->iso8601;
while ( my $rating = $parser->fetch ) {
next unless ( $rating->{review_count} );
my $data = {
Expand All @@ -59,16 +64,14 @@ sub run {
};

for ( my $i = 0; $i < $rating->{review_count}; $i++ ) {
$bulk->put(
$bulk->create(
{
index => $index,
type => 'rating',
body => Dlog_trace {$_} $data,
source => Dlog_trace {$_} $data,
}
);
}
}
$bulk->commit;
$bulk->flush;
$self->index->refresh;
log_info {'done'};
}
Expand Down
23 changes: 23 additions & 0 deletions lib/MetaCPAN/Script/Tickets.pm
Expand Up @@ -4,6 +4,9 @@ use strict;
use warnings;
use namespace::autoclean;

# Some issue with rt.cpan.org's cert
$ENV{PERL_LWP_SSL_VERIFY_HOSTNAME} = 0;

use HTTP::Request::Common;
use IO::String;
use LWP::UserAgent;
Expand Down Expand Up @@ -214,3 +217,23 @@ sub rt_dist_url {
__PACKAGE__->meta->make_immutable;

1;

=pod
=head1 SYNOPSIS
# bin/metacpan tickets
=head1 DESCRIPTION
Tracks the number of issues and the source, if the issue
tracker is RT or Github it fetches the info and updates
out ES information.
This can then be accessed here:
http://api.metacpan.org/distribution/Moose
http://api.metacpan.org/distribution/HTTP-BrowserDetect
=cut

0 comments on commit 44fb92d

Please sign in to comment.