Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
Merge branch 'master' into mickey/use_rating_by_distribution_endpoint
  • Loading branch information
oalders committed Jul 5, 2017
2 parents 4e6091f + 026ba61 commit 076a9c0
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 36 deletions.
5 changes: 2 additions & 3 deletions lib/MetaCPAN/Web/Controller/Pod.pm
Expand Up @@ -58,8 +58,7 @@ sub distribution : Local : Args {
# Get latest "author/release" of dist so we can use it to find the file.
# TODO: Pass size param so we can disambiguate?
my $release = try {
$c->model('API::Release')->find($dist)->get->{hits}{hits}->[0]
->{_source};
$c->model('API::Release')->find($dist)->get->{release};
} or $c->detach('/not_found');

# TODO: Disambiguate if there's more than once match. #176
Expand Down Expand Up @@ -202,7 +201,7 @@ sub view : Private {
},
);
my $release = $reqs->{release}->{hits}->{hits}->[0]->{_source};
my $release = $reqs->{release}{release};
#<<<
my $canonical = ( $documented_module
Expand Down
3 changes: 2 additions & 1 deletion lib/MetaCPAN/Web/Controller/Release.pm
Expand Up @@ -55,6 +55,7 @@ sub by_author_and_release : Chained('root') PathPart('') Args(2) {

$c->stash->{permalinks} = 1;
$c->stash->{data} = $model->get( $author, $release );

$c->forward('view');
}

Expand All @@ -63,7 +64,7 @@ sub view : Private {

my $model = $c->stash->{model};
my $data = delete $c->stash->{data};
my $out = $data->get->{hits}->{hits}->[0]->{_source};
my $out = $data->get->{release};

$c->detach('/not_found') unless ($out);

Expand Down
34 changes: 2 additions & 32 deletions lib/MetaCPAN/Web/Model/API/Release.pm
Expand Up @@ -27,19 +27,7 @@ it under the same terms as Perl itself.

sub get {
my ( $self, $author, $release ) = @_;
$self->request(
'/release/_search',
{
query => {
bool => {
must => [
{ term => { 'name' => $release } },
{ term => { author => uc($author) } }
]
}
}
}
);
$self->request("/release/by_author_and_name/$author/$release");
}

sub distribution {
Expand Down Expand Up @@ -78,25 +66,7 @@ sub modules {

sub find {
my ( $self, $distribution ) = @_;
$self->request(
'/release/_search',
{
query => {
bool => {
must => [
{
term => {
'distribution' => $distribution
}
},
{ term => { status => 'latest' } }
]
}
},
sort => [ { date => 'desc' } ],
size => 1
}
);
$self->request("/release/latest_by_distribution/$distribution");
}

# stolen from Module/requires
Expand Down

0 comments on commit 076a9c0

Please sign in to comment.