Skip to content

Commit

Permalink
Merge 5e259db into 3f4f5c6
Browse files Browse the repository at this point in the history
  • Loading branch information
tsibley committed Nov 18, 2016
2 parents 3f4f5c6 + 5e259db commit d9d5529
Showing 1 changed file with 10 additions and 4 deletions.
14 changes: 10 additions & 4 deletions lib/MetaCPAN/Web/Model/API/Module.pm
Original file line number Diff line number Diff line change
Expand Up @@ -80,15 +80,15 @@ sub search_expanded {
}
)->recv;

my @distributions = uniq
map { $_->{fields}->{distribution} } @{ $data->{hits}->{hits} };

# Everything after this will fail (slowly and silently) without results.
if ( !$data->{hits}->{total} ) {
unless (@distributions) {
$cv->send( {} );
return $cv;
}

my @distributions = uniq
map { $_->{fields}->{distribution} } @{ $data->{hits}->{hits} };

my @ids = map { $_->{fields}->{id} } @{ $data->{hits}->{hits} };
my $descriptions = $self->search_descriptions(@ids);
my $ratings = $self->model('Rating')->get(@distributions);
Expand Down Expand Up @@ -167,6 +167,12 @@ sub search_collapsed {
sub search_descriptions {
my ( $self, @ids ) = @_;
my $cv = $self->cv;

unless (@ids) {
$cv->send( {} );
return $cv;
}

$self->request(
'/file/_search',
{
Expand Down

0 comments on commit d9d5529

Please sign in to comment.