Skip to content

Commit 4912ce5

Browse files
committed
return full structure even when no results found in author queries
1 parent d00dac5 commit 4912ce5

File tree

1 file changed

+10
-5
lines changed

1 file changed

+10
-5
lines changed

lib/MetaCPAN/Query/Author.pm

Lines changed: 10 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -26,14 +26,17 @@ sub by_ids {
2626
type => 'author',
2727
body => $body,
2828
);
29-
return {} unless $authors->{hits}{total};
3029

3130
my @authors = map {
3231
single_valued_arrayref_to_scalar( $_->{_source} );
3332
$_->{_source}
3433
} @{ $authors->{hits}{hits} };
3534

36-
return { authors => \@authors };
35+
return {
36+
authors => \@authors,
37+
took => $authors->{took},
38+
total => $authors->{hits}{total},
39+
};
3740
}
3841

3942
sub by_user {
@@ -48,14 +51,17 @@ sub by_user {
4851
size => 500,
4952
}
5053
);
51-
return {} unless $authors->{hits}{total};
5254

5355
my @authors = map {
5456
single_valued_arrayref_to_scalar( $_->{_source} );
5557
$_->{_source}
5658
} @{ $authors->{hits}{hits} };
5759

58-
return { authors => \@authors };
60+
return {
61+
authors => \@authors,
62+
took => $authors->{took},
63+
total => $authors->{hits}{total},
64+
};
5965
}
6066

6167
sub search {
@@ -91,7 +97,6 @@ sub search {
9197
type => 'author',
9298
body => $body,
9399
);
94-
return {} unless $ret->{hits}{total};
95100

96101
my @authors = map {
97102
single_valued_arrayref_to_scalar( $_->{_source} );

0 commit comments

Comments
 (0)