Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

use bulk indexing

  • Loading branch information...
commit 52b992cb4197a5ddfb62862751a90c50ce00657e 1 parent 345566e
Moritz Onken monken authored oalders committed
Showing with 14 additions and 6 deletions.
  1. +14 −6 lib/MetaCPAN/Script/Tickets.pm
20 lib/MetaCPAN/Script/Tickets.pm
View
@@ -29,16 +29,22 @@ sub run {
sub index_bug_summary {
my ( $self, $summary ) = @_;
+ my $bulk = $self->index->bulk( size => 300 );
for my $dist ( keys %{$summary} ) {
my $dist_data = $self->index->type('distribution')->raw->get($dist)
or next;
- $self->index->type('distribution')->put(
- { %{ $dist_data->{_source} }, rt_bug_count => $summary->{$dist},
- },
- { refresh => 1 }
+ delete $dist_data->{exists};
+ $bulk->put(
+ { %$dist_data,
+ _source => {
+ %{ $dist_data->{_source} },
+ rt_bug_count => $summary->{$dist},
+ }
+ }
);
}
+ $bulk->commit;
}
sub retrieve_bug_summary {
@@ -56,8 +62,10 @@ sub parse_tsv {
my ( $self, $tsv ) = @_;
$tsv =~ s/^#.*\n//mg;
- my $tsv_parser = Parse::CSV->new( handle => IO::String->new($tsv),
- sep_char => "\t" );
+ my $tsv_parser = Parse::CSV->new(
+ handle => IO::String->new($tsv),
+ sep_char => "\t"
+ );
my %summary;
while ( my $row = $tsv_parser->fetch ) {
Please sign in to comment.
Something went wrong with that request. Please try again.