Skip to content

Commit 24d6e6a

Browse files
committed
Added first script
1 parent 7703dc3 commit 24d6e6a

File tree

1 file changed

+76
-0
lines changed

1 file changed

+76
-0
lines changed

bin/first.pl

Lines changed: 76 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,76 @@
1+
use strict;
2+
use warnings;
3+
use v5.36;
4+
5+
use Getopt::Long;
6+
use MetaCPAN::Logger qw< :log :dlog >;
7+
8+
use MetaCPAN::ES;
9+
10+
# args
11+
my ($distribution);
12+
GetOptions( "distribution=s" => \$distribution, );
13+
14+
# setup
15+
my $es = MetaCPAN::ES->new( type => "distribution" );
16+
17+
my $query
18+
= $distribution
19+
? { term => { name => $distribution } }
20+
: { match_all => {} };
21+
22+
my $size
23+
= $distribution
24+
? 1
25+
: 500;
26+
27+
my $scroll = $es->scroll(
28+
body => {
29+
query => $query,
30+
size => $size,
31+
},
32+
);
33+
34+
log_info { "processing " . $scroll->total . " distributions" };
35+
36+
while ( my $distribution = $scroll->next ) {
37+
my $release = $distribution->set_first_release;
38+
$release
39+
? log_debug {
40+
"@{[ $release->name ]} by @{[ $release->author ]} was first"
41+
}
42+
: log_warn {
43+
"no release found for distribution @{[$distribution->name]}"
44+
};
45+
}
46+
47+
# Everything changed - reboot the world!
48+
# cdn_purge_all;
49+
50+
1;
51+
52+
__END__
53+
54+
=pod
55+
56+
=head1 NAME
57+
58+
Set the C<first> bit after a full reindex
59+
60+
=head1 SYNOPSIS
61+
62+
$ bin/first --distribution Moose
63+
64+
=head1 DESCRIPTION
65+
66+
Setting the C<first> bit cannot be set when indexing archives in parallel,
67+
e.g. when doing a full reindex.
68+
This script sets the C<first> bit once all archives have been indexed.
69+
70+
=head1 OPTIONS
71+
72+
=head2 distribution
73+
74+
Only set the C<first> bit for releases of this distribution.
75+
76+
=cut

0 commit comments

Comments
 (0)