Skip to content

Commit

Permalink
Merge branch 'master' into mickey/use_new_release_endpoints
Browse files Browse the repository at this point in the history
  • Loading branch information
oalders committed Jul 5, 2017
2 parents e197523 + edcbaa6 commit 9278f86
Show file tree
Hide file tree
Showing 4 changed files with 8 additions and 68 deletions.
2 changes: 1 addition & 1 deletion lib/MetaCPAN/Web/Controller/Recent.pm
Expand Up @@ -21,7 +21,7 @@ sub index : Path : Args(0) {
{
recent => $data->{releases},
took => $data->{took},
total => $data->{hits}->{total},
total => $data->{total},
template => 'recent.html',
page_size => $page_size,
}
Expand Down
11 changes: 4 additions & 7 deletions lib/MetaCPAN/Web/Controller/Recent/TopUploaders.pm
Expand Up @@ -33,13 +33,10 @@ sub topuploaders : Private {
$c->stash(
{
authors => [
sort { $b->{releases} <=> $a->{releases} } map {
{
%{ $_->{_source} },
releases =>
$data->{counts}{ $_->{_source}->{pauseid} }
}
} @{ $authors->{hits}{hits} }
sort { $b->{releases} <=> $a->{releases} }
map +{ %{$_},
releases => $data->{counts}{ $_->{pauseid} } },
@{ $authors->{authors} }
],
took => $data->{took},
total => $data->{total},
Expand Down
13 changes: 1 addition & 12 deletions lib/MetaCPAN/Web/Model/API/Author.pm
Expand Up @@ -32,18 +32,7 @@ sub get {
return $self->request( '/author/' . uc( $author[0] ) )
if ( @author == 1 );

return $self->request(
'/author/_search',
{
query => {
constant_score => {
filter => { ids => { values => [ map {uc} @author ] } }
}
},
size => scalar @author,
}
);

return $self->request( '/author/by_ids', { id => \@author } );
}

sub search {
Expand Down
50 changes: 2 additions & 48 deletions lib/MetaCPAN/Web/Model/API/Favorite.pm
Expand Up @@ -17,54 +17,8 @@ sub get {
return Future->wrap( {} );
}

return $self->request(
'/favorite/_search',
{
size => 0,
query => {
terms => { 'distribution' => \@distributions }
},
aggregations => {
favorites => {
terms => {
field => 'distribution',
size => scalar @distributions,
},
},
$user
? (
myfavorites => {
filter => { term => { 'user' => $user } },
aggregations => {
enteries => {
terms => { field => 'distribution' }
}
}
}
)
: (),
}
}
)->transform(
done => sub {
my $data = shift;
return {
took => $data->{took},
favorites => {
map { $_->{key} => $_->{doc_count} }
@{ $data->{aggregations}->{favorites}->{buckets} }
},
myfavorites => $user
? {
map { $_->{key} => $_->{doc_count} } @{
$data->{aggregations}->{myfavorites}->{entries}
->{buckets}
}
}
: {},
};
}
);
return $self->request( '/favorite/agg_by_distributions',
{ user => $user, distribution => \@distributions } );
}

sub by_user {
Expand Down

0 comments on commit 9278f86

Please sign in to comment.