Skip to content

Commit

Permalink
Merge pull request #41 from metacpan/mickey/first
Browse files Browse the repository at this point in the history
Added first script
  • Loading branch information
mickeyn authored Sep 30, 2024
2 parents 7703dc3 + 24d6e6a commit d828ca8
Showing 1 changed file with 76 additions and 0 deletions.
76 changes: 76 additions & 0 deletions bin/first.pl
Original file line number Diff line number Diff line change
@@ -0,0 +1,76 @@
use strict;
use warnings;
use v5.36;

use Getopt::Long;
use MetaCPAN::Logger qw< :log :dlog >;

use MetaCPAN::ES;

# args
my ($distribution);
GetOptions( "distribution=s" => \$distribution, );

# setup
my $es = MetaCPAN::ES->new( type => "distribution" );

my $query
= $distribution
? { term => { name => $distribution } }
: { match_all => {} };

my $size
= $distribution
? 1
: 500;

my $scroll = $es->scroll(
body => {
query => $query,
size => $size,
},
);

log_info { "processing " . $scroll->total . " distributions" };

while ( my $distribution = $scroll->next ) {
my $release = $distribution->set_first_release;
$release
? log_debug {
"@{[ $release->name ]} by @{[ $release->author ]} was first"
}
: log_warn {
"no release found for distribution @{[$distribution->name]}"
};
}

# Everything changed - reboot the world!
# cdn_purge_all;

1;

__END__
=pod
=head1 NAME
Set the C<first> bit after a full reindex
=head1 SYNOPSIS
$ bin/first --distribution Moose
=head1 DESCRIPTION
Setting the C<first> bit cannot be set when indexing archives in parallel,
e.g. when doing a full reindex.
This script sets the C<first> bit once all archives have been indexed.
=head1 OPTIONS
=head2 distribution
Only set the C<first> bit for releases of this distribution.
=cut

0 comments on commit d828ca8

Please sign in to comment.