Skip to content

Commit

Permalink
be more resilient to bad data when updating contributors
Browse files Browse the repository at this point in the history
When trying to update all contributor data, it will fail because there
are some broken releases in the index. While those should be fixed, they
shouldn't cause the contributor script to fail.
  • Loading branch information
haarg committed Nov 21, 2024
1 parent 232b751 commit 12ed9b1
Showing 1 changed file with 20 additions and 1 deletion.
21 changes: 20 additions & 1 deletion lib/MetaCPAN/Script/Role/Contributor.pm
Original file line number Diff line number Diff line change
Expand Up @@ -25,9 +25,28 @@ sub update_contributors {
},
);

my $bulk = $self->es->bulk_helper( es_doc_path('contributor') );
my $report = sub {
my ( $action, $result, $i ) = @_;
if ( $i == 0 ) {
log_info {'flushing contributor updates'};
}
};

my $bulk = $self->es->bulk_helper(
es_doc_path('contributor'),
on_success => $report,
on_error => $report,
);

log_info { 'updating contributors for ' . $scroll->total . ' releases' };

while ( my $release = $scroll->next ) {
my $source = $release->{_source};
my $name = $source->{name};
if ( !( $name && $source->{author} && $source->{distribution} ) ) {
Dlog_warn {"found broken release: $_"} $release;
next;
}
log_debug { 'updating contributors for ' . $release->{_source}{name} };
my $actions = $self->release_contributor_update_actions(
$release->{_source} );
Expand Down

0 comments on commit 12ed9b1

Please sign in to comment.