Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Adds script for setting 'backpan' status without re-indexing.
- Loading branch information
Showing
2 changed files
with
75 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -126,7 +126,6 @@ sub _build_logger { | |
} | ||
|
||
sub file2mod { | ||
|
||
my $self = shift; | ||
my $name = shift; | ||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,75 @@ | ||
package MetaCPAN::Script::Backpan; | ||
|
||
use strict; | ||
use warnings; | ||
|
||
use BackPAN::Index; | ||
use Moose; | ||
|
||
with 'MetaCPAN::Role::Common', 'MooseX::Getopt::Dashes'; | ||
|
||
sub run { | ||
my $self = shift; | ||
|
||
my $backpan = BackPAN::Index->new( debug => 0 ); | ||
my $releases = $backpan->releases(); | ||
|
||
my @search; | ||
while ( my $release = $releases->next ) { | ||
push @search, | ||
{ | ||
and => [ | ||
{ term => { 'author' => $release->cpanid } }, | ||
{ term => { 'name' => $release->distvname } }, | ||
{ not => { term => { status => 'backpan' } } }, | ||
] | ||
}; | ||
if ( scalar @search >= 5000 ) { | ||
$self->update_status(@search); | ||
@search = (); | ||
} | ||
} | ||
$self->update_status(@search) if @search; | ||
} | ||
|
||
sub update_status { | ||
my $self = shift; | ||
my @search = @_; | ||
|
||
my $es = $self->es; | ||
$es->trace_calls(1) if $ENV{DEBUG}; | ||
|
||
my $scroll = $es->scrolled_search( | ||
size => 500, | ||
scroll => '2m', | ||
index => 'cpan_v1', | ||
type => 'release', | ||
fields => [ 'author', 'name' ], | ||
query => { | ||
filtered => { | ||
query => { match_all => {} }, | ||
filter => { | ||
or => \@search, | ||
}, | ||
}, | ||
}, | ||
); | ||
|
||
while ( my $release = $scroll->next ) { | ||
$es->update( | ||
index => 'cpan_v1', | ||
type => 'release', | ||
id => $release->{_id}, | ||
doc => { status => 'backpan' } | ||
); | ||
} | ||
} | ||
|
||
__PACKAGE__->meta->make_immutable; | ||
1; | ||
|
||
=pod | ||
Sets "backpan" status on all BackPAN releases. | ||
=cut |
ae0a3e1
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think you also need to set
status: backpan
on all the files contained within a release.