From 24d6e6ac2bc3d78d2b3307d12d824350588a82e5 Mon Sep 17 00:00:00 2001 From: Mickey Nasriachi Date: Mon, 30 Sep 2024 20:57:43 +0200 Subject: [PATCH] Added first script --- bin/first.pl | 76 ++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 76 insertions(+) create mode 100644 bin/first.pl diff --git a/bin/first.pl b/bin/first.pl new file mode 100644 index 0000000..75ba9d8 --- /dev/null +++ b/bin/first.pl @@ -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 bit after a full reindex + +=head1 SYNOPSIS + + $ bin/first --distribution Moose + +=head1 DESCRIPTION + +Setting the C bit cannot be set when indexing archives in parallel, +e.g. when doing a full reindex. +This script sets the C bit once all archives have been indexed. + +=head1 OPTIONS + +=head2 distribution + +Only set the C bit for releases of this distribution. + +=cut