Skip to content

Commit

Permalink
limit size of author searches
Browse files Browse the repository at this point in the history
  • Loading branch information
haarg committed Jan 29, 2025
1 parent 0b2f286 commit 0db7140
Showing 1 changed file with 13 additions and 2 deletions.
15 changes: 13 additions & 2 deletions lib/MetaCPAN/Query/Author.pm
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ package MetaCPAN::Query::Author;
use MetaCPAN::Moose;

use MetaCPAN::ESConfig qw( es_doc_path );
use MetaCPAN::Util qw(hit_total);
use MetaCPAN::Util qw( MAX_RESULT_WINDOW hit_total );
use Ref::Util qw( is_arrayref );

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

$from //= 0;
my $size = 10;

if ( $from * $size >= MAX_RESULT_WINDOW ) {
return +{
authors => [],
took => 0,
total => 0,
};
}

my $body = {
query => {
bool => {
Expand All @@ -74,7 +85,7 @@ sub search {
],
}
},
size => 10,
size => $size,
from => $from || 0,
};

Expand Down

0 comments on commit 0db7140

Please sign in to comment.