Skip to content

Commit 0db7140

Browse files
committed
limit size of author searches
1 parent 0b2f286 commit 0db7140

File tree

1 file changed

+13
-2
lines changed

1 file changed

+13
-2
lines changed

lib/MetaCPAN/Query/Author.pm

Lines changed: 13 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ package MetaCPAN::Query::Author;
33
use MetaCPAN::Moose;
44

55
use MetaCPAN::ESConfig qw( es_doc_path );
6-
use MetaCPAN::Util qw(hit_total);
6+
use MetaCPAN::Util qw( MAX_RESULT_WINDOW hit_total );
77
use Ref::Util qw( is_arrayref );
88

99
with 'MetaCPAN::Query::Role::Common';
@@ -53,6 +53,17 @@ sub by_user {
5353
sub search {
5454
my ( $self, $query, $from ) = @_;
5555

56+
$from //= 0;
57+
my $size = 10;
58+
59+
if ( $from * $size >= MAX_RESULT_WINDOW ) {
60+
return +{
61+
authors => [],
62+
took => 0,
63+
total => 0,
64+
};
65+
}
66+
5667
my $body = {
5768
query => {
5869
bool => {
@@ -74,7 +85,7 @@ sub search {
7485
],
7586
}
7687
},
77-
size => 10,
88+
size => $size,
7889
from => $from || 0,
7990
};
8091

0 commit comments

Comments
 (0)