Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
Use new /reverse_dependencies API endpoints
1. /requires/distribution
Removed the query currently being sent to
/search/reverse_dependencies and switched dist rev. deps to use
new API endpoint.

2. /requires/module
Use the new API endpoint instead of the current one.
  • Loading branch information
mickeyn committed Jun 16, 2017
1 parent d79fa83 commit 11135e6
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 28 deletions.
2 changes: 1 addition & 1 deletion lib/MetaCPAN/Web/Model/API/Module.pm
Expand Up @@ -63,7 +63,7 @@ sub requires {
my ( $self, $module, $page, $page_size ) = @_;

$self->request(
"/release/requires/$module",
"/reverse_dependencies/module/$module",
undef,
{
page => $page,
Expand Down
29 changes: 2 additions & 27 deletions lib/MetaCPAN/Web/Model/API/Release.pm
Expand Up @@ -207,33 +207,8 @@ sub reverse_dependencies {
my ( $self, $distribution, $page, $page_size, $sort ) = @_;
$sort ||= { date => 'desc' };

# TODO: do we need to do a taint-check on $distribution before inserting it into the url?
# maybe the fact that it came through as a Catalyst Arg is enough?
return $self->request(
"/search/reverse_dependencies/$distribution",
{
query => {
bool => {
must => [
{ term => { 'status' => 'latest' } },
{ term => { 'authorized' => 1 } },
]
}
},
size => $page_size,
from => $page * $page_size - $page_size,
sort => [$sort],
}
)->transform(
done => sub {
my $data = shift;
return {
data => [ map { $_->{_source} } @{ $data->{hits}->{hits} } ],
total => $data->{hits}->{total},
took => $data->{took}
};
}
);
return $self->request( "/reverse_dependencies/dist/$distribution",
undef, { sort => $sort } );
}

sub interesting_files {
Expand Down

0 comments on commit 11135e6

Please sign in to comment.