Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 2 additions & 3 deletions lib/MetaCPAN/Web/Controller/Pod.pm
Original file line number Diff line number Diff line change
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
Original file line number Diff line number Diff line change
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
Original file line number Diff line number Diff line change
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