Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
Merge branch 'master' into mickey/use_release_by_author_endpoint
  • Loading branch information
oalders committed Jul 4, 2017
2 parents 391eeb1 + 592bfb7 commit e5fc0ae
Show file tree
Hide file tree
Showing 5 changed files with 7 additions and 31 deletions.
9 changes: 2 additions & 7 deletions lib/MetaCPAN/Web/Controller/Feed.pm
Expand Up @@ -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 ) = @_;
}
Expand Down Expand Up @@ -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},
);
}

Expand Down
2 changes: 1 addition & 1 deletion lib/MetaCPAN/Web/Controller/Release.pm
Expand Up @@ -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,
Expand Down
11 changes: 1 addition & 10 deletions lib/MetaCPAN/Web/Model/API/Release.pm
Expand Up @@ -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 {
Expand Down
3 changes: 1 addition & 2 deletions lib/MetaCPAN/Web/Role/ReleaseInfo.pm
Expand Up @@ -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
Expand Down
13 changes: 2 additions & 11 deletions t/model/release.t
Expand Up @@ -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.
Expand Down Expand Up @@ -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] );
Expand Down

0 comments on commit e5fc0ae

Please sign in to comment.