Skip to content

Commit

Permalink
fix queries (--> fixes test t/controller/release.t)
Browse files Browse the repository at this point in the history
  • Loading branch information
mickeyn committed May 23, 2016
1 parent b40e418 commit a51b9fc
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 4 deletions.
16 changes: 15 additions & 1 deletion lib/MetaCPAN/Web/Controller/Release.pm
Expand Up @@ -2,6 +2,9 @@ package MetaCPAN::Web::Controller::Release;

use Moose;

use Importer 'MetaCPAN::Web::Elasticsearch::Adapter' =>
qw/ single_valued_arrayref_to_scalar /;

use namespace::autoclean;

BEGIN { extends 'MetaCPAN::Web::Controller' }
Expand Down Expand Up @@ -87,6 +90,7 @@ sub view : Private {
my @root_files = (
sort { $a->{name} cmp $b->{name} }
grep { $_->{path} !~ m{/} }
map { single_valued_arrayref_to_scalar($_) }
map { $_->{fields} } @{ $files->{hits}->{hits} }
);

Expand All @@ -96,6 +100,7 @@ sub view : Private {
$_->{path} =~ m{\b(?:eg|ex|examples?|samples?)\b}i
and not $_->{path} =~ m{^x?t/}
}
map { single_valued_arrayref_to_scalar($_) }
map { $_->{fields} } @{ $files->{hits}->{hits} }
);

Expand All @@ -115,7 +120,16 @@ sub view : Private {
$c->stash( $c->model('API::Favorite')->find_plussers($distribution) );

# Simplify the file data we pass to the template.
my @view_files = map { $_->{fields} } @{ $modules->{hits}->{hits} };
my @view_files = map { single_valued_arrayref_to_scalar($_) }
map +{
%{ $_->{fields} },
module => [
( exists $_->{_source} and $_->{_source}{module} )
? $_->{_source}{module}
: ()
],
},
@{ $modules->{hits}->{hits} };

my $changes
= $c->model('API::Changes')->last_version( $reqs->{changes}, $out );
Expand Down
2 changes: 1 addition & 1 deletion lib/MetaCPAN/Web/Model/API/Favorite.pm
Expand Up @@ -132,7 +132,7 @@ sub find_plussers {

# store in an array.
my @plusser_users
= map { $_->{fields}->{user} } @{ $plusser_data->{hits}->{hits} };
= map { $_->{fields}->{user}[0] } @{ $plusser_data->{hits}->{hits} };
my $total_plussers = @plusser_users;

# find plussers by pause ids.
Expand Down
4 changes: 2 additions & 2 deletions lib/MetaCPAN/Web/Model/API/Release.pm
Expand Up @@ -194,6 +194,8 @@ sub modules {
# Sort by documentation name; if there isn't one, sort by path.
sort => [ 'documentation', 'path' ],

_source => [ "module", "abstract" ],

fields => [
qw(
author
Expand All @@ -204,8 +206,6 @@ sub modules {
path
pod_lines
release
_source.abstract
_source.module
status
)
],
Expand Down

0 comments on commit a51b9fc

Please sign in to comment.