Skip to content

Commit bd4af40

Browse files
authored
Merge pull request #1355 from metacpan/haarg/latest-without-model
drop use of model in latest script
2 parents 19a0db7 + 5d32904 commit bd4af40

File tree

1 file changed

+27
-6
lines changed

1 file changed

+27
-6
lines changed

lib/MetaCPAN/Script/Latest.pm

+27-6
Original file line numberDiff line numberDiff line change
@@ -260,17 +260,38 @@ sub reindex {
260260
my ( $self, $bulk, $source, $status ) = @_;
261261

262262
# Update the status on the release.
263-
my $release = $self->model->doc('release')->get( {
264-
author => $source->{author},
265-
name => $source->{release},
263+
my $releases = $self->es->search( {
264+
es_doc_path('release'),
265+
body => {
266+
query => {
267+
bool => {
268+
must => [
269+
{ term => { author => $source->{author} } },
270+
{ term => { name => $source->{release} } },
271+
],
272+
},
273+
},
274+
},
275+
_source => false,
266276
} );
277+
my $release = $releases->{hits}{hits}[0]{_id};
267278

268-
$release->_set_status($status);
269279
log_info {
270280
$status eq 'latest' ? 'Upgrading ' : 'Downgrading ',
271-
'release ', $release->name || q[];
281+
'release ', $source->{release}, "($release)";
272282
};
273-
$release->put unless ( $self->dry_run );
283+
284+
if ( !$self->dry_run ) {
285+
$self->es->update( {
286+
es_doc_path('release'),
287+
id => $release,
288+
body => {
289+
doc => {
290+
status => $status,
291+
},
292+
},
293+
} );
294+
}
274295

275296
# Get all the files for the release.
276297
my $scroll = $self->es->scroll_helper(

0 commit comments

Comments
 (0)