Skip to content

Commit 36ada25

Browse files
authored
Merge pull request #1280 from metacpan/haarg/fix-latest-perf
Fix performance of latest script
2 parents a5dc636 + 6e1da8f commit 36ada25

File tree

2 files changed

+21
-3
lines changed

2 files changed

+21
-3
lines changed

lib/MetaCPAN/Script/Latest.pm

Lines changed: 13 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -139,9 +139,19 @@ sub run {
139139
'Searching for ' . @$filter . ' of ' . $total . ' modules'
140140
}
141141
if @module_filters > 1;
142-
my $scroll = $self->index->type('file')->query($query)->source( [ qw(
143-
author date distribution download_url module.name release status
144-
) ] )->size(100)->raw->scroll;
142+
143+
my $scroll = $self->es->scroll_helper( {
144+
index => $self->index->name,
145+
type => 'file',
146+
size => 100,
147+
body => {
148+
query => $query,
149+
_source => [
150+
qw(author date distribution download_url module.name release status)
151+
],
152+
sort => '_doc',
153+
},
154+
} );
145155

146156
$found_total += $scroll->total;
147157

lib/MetaCPAN/Script/Runner.pm

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,14 @@ sub run {
2929
or File::Path::mkpath($path);
3030
}
3131

32+
if ( -t *STDERR ) {
33+
push @{ $config->{logger} },
34+
{
35+
class => 'Log::Log4perl::Appender::ScreenColoredLevels',
36+
stdout => 0,
37+
};
38+
}
39+
3240
my $obj = undef;
3341
my $ex = undef;
3442
try {

0 commit comments

Comments
 (0)