Skip to content

Commit

Permalink
correct data extraction from query results
Browse files Browse the repository at this point in the history
  • Loading branch information
mickeyn committed May 24, 2016
1 parent 616b1b8 commit 6b3eaec
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 3 deletions.
8 changes: 6 additions & 2 deletions lib/MetaCPAN/Web/Model/API/Favorite.pm
Expand Up @@ -6,6 +6,9 @@ extends 'MetaCPAN::Web::Model::API';

use List::MoreUtils qw(uniq);

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

sub get {
my ( $self, $user, @distributions ) = @_;
@distributions = uniq @distributions;
Expand Down Expand Up @@ -131,8 +134,9 @@ sub find_plussers {
my $plusser_data = $plusser->recv;

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

# find plussers by pause ids.
Expand Down
2 changes: 1 addition & 1 deletion lib/MetaCPAN/Web/Model/API/Module.pm
Expand Up @@ -94,7 +94,7 @@ sub search_expanded {
my $favorites = $self->model('Favorite')->get( $user, @distributions );
$_ = $_->recv for ( $ratings, $favorites, $descriptions );
my $results = $self->_extract_results( $data, $ratings, $favorites );
map { $_->{description} = $descriptions->{results}->{ $_->{id}[0] } }
map { $_->{description} = $descriptions->{results}->{ $_->{id} } }
@{$results};
$cv->send(
{
Expand Down

0 comments on commit 6b3eaec

Please sign in to comment.