Permalink
Browse files

Merge pull request #1926 from metacpan/mickey/use_versions_ep

Use /release/versions API endpoint
  • Loading branch information...
2 parents 9c864d7 + 523ee90 commit 592bfb7ac1b8fbb8c367f997ed6533a7bdd9cee7 @oalders oalders committed Jul 4, 2017
@@ -14,9 +14,6 @@ use Path::Tiny qw/path/;
use Text::Markdown qw/markdown/;
use XML::Feed ();
-use Importer 'MetaCPAN::Web::Elasticsearch::Adapter' =>
- qw/ single_valued_arrayref_to_scalar /;
-
sub feed_index : PathPart('feed') : Chained('/') : CaptureArgs(0) {
my ( $self, $c ) = @_;
}
@@ -137,13 +134,11 @@ sub distribution : Local : Args(1) {
$c->add_dist_key($distribution);
my $data = $c->model('API::Release')->versions($distribution)->get;
+
$c->stash->{feed} = $self->build_feed(
host => $c->config->{web_host},
title => "Recent CPAN uploads of $distribution - MetaCPAN",
- entries => [
- map { single_valued_arrayref_to_scalar($_) }
- map { $_->{fields} } @{ $data->{hits}->{hits} }
- ]
+ entries => $data->{releases},
);
}
@@ -131,7 +131,7 @@ sub view : Private {
release => $out,
total => $modules->{total},
took => List::Util::max(
- $modules->{took}, $files->{took}, $reqs->{versions}->{took}
+ $modules->{took}, $files->{took}, $reqs->{versions}{took}
),
root => \@root_files,
examples => \@examples,
@@ -115,16 +115,7 @@ sub interesting_files {
sub versions {
my ( $self, $dist ) = @_;
- $self->request(
- '/release/_search',
- {
- query => { term => { distribution => $dist } },
- size => 250,
- sort => [ { date => 'desc' } ],
- fields =>
- [qw( name date author version status maturity authorized )],
- }
- );
+ $self->request("/release/versions/$dist");
}
sub topuploaders {
@@ -67,8 +67,7 @@ sub stash_api_results {
author => $reqs->{author},
distribution => $reqs->{distribution},
rating => $reqs->{rating}->{ratings}->{ $data->{distribution} },
- versions =>
- [ map { $_->{fields} } @{ $reqs->{versions}->{hits}->{hits} } ],
+ versions => $reqs->{versions}{releases},
);
my %stash
View
@@ -8,14 +8,6 @@ use MetaCPAN::Web;
use Importer 'MetaCPAN::Web::Elasticsearch::Adapter' =>
qw/ single_valued_arrayref_to_scalar /;
-sub search_release {
- my ( $method, @args ) = @_;
-
- return
- map { @{ $_->{hits}{hits} } }
- MetaCPAN::Web->model('API::Release')->$method(@args)->get;
-}
-
my ( $true, $false ) = @{ decode_json('[true, false]') };
# Explicitly test that we get a boolean.
@@ -60,15 +52,14 @@ subtest versions => sub {
# Something with not too many versions.
my @versions
- = map { $_->{fields} }
- search_release( versions => 'Mojolicious-Plugin-HamlRenderer' );
+ = @{ MetaCPAN::Web->model('API::Release')
+ ->versions('Mojolicious-Plugin-HamlRenderer')->get->{releases} };
ok( scalar @versions, 'found release versions' );
my %statuses;
my @dates;
foreach my $version (@versions) {
- single_valued_arrayref_to_scalar($version);
# Ensure we get a boolean so that conditions work as expected.
is_bool( $version->{authorized}, q['authorized' is a boolean] );

0 comments on commit 592bfb7

Please sign in to comment.