-
Notifications
You must be signed in to change notification settings - Fork 194
/
Copy pathContributor.pm
67 lines (55 loc) · 1.55 KB
/
Contributor.pm
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
package MetaCPAN::Query::Contributor;
use MetaCPAN::Moose;
use MetaCPAN::ESConfig qw( es_doc_path );
use MetaCPAN::Util qw(hit_total);
with 'MetaCPAN::Query::Role::Common';
sub find_release_contributors {
my ( $self, $author, $name ) = @_;
my $query = +{
bool => {
must => [
{ term => { release_author => $author } },
{ term => { release_name => $name } },
{ exists => { field => 'pauseid' } },
]
}
};
my $res = $self->es->search(
es_doc_path('contributor'),
body => {
query => $query,
size => 999,
_source => [ qw(
distribution
pauseid
release_author
release_name
) ],
}
);
hit_total($res) or return {};
return +{
contributors => [ map { $_->{_source} } @{ $res->{hits}{hits} } ] };
}
sub find_author_contributions {
my ( $self, $pauseid ) = @_;
my $query = +{ term => { pauseid => $pauseid } };
my $res = $self->es->search(
es_doc_path('contributor'),
body => {
query => $query,
size => 999,
_source => [ qw(
distribution
pauseid
release_author
release_name
) ],
}
);
hit_total($res) or return {};
return +{
contributors => [ map { $_->{_source} } @{ $res->{hits}{hits} } ] };
}
__PACKAGE__->meta->make_immutable;
1;