Skip to content

Commit

Permalink
Get indexed/authorized from _source to work around ES bug
Browse files Browse the repository at this point in the history
closes #881.
  • Loading branch information
rwstauner committed Jul 24, 2013
1 parent 733f309 commit 08a450f
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 10 deletions.
23 changes: 14 additions & 9 deletions lib/MetaCPAN/Web/Controller/Release.pm
Expand Up @@ -87,6 +87,19 @@ sub view : Private {

$self->groom_contributors( $c, $out );

# Simplify the file data we pass to the template.
my @view_files;
foreach my $hit ( @{ $modules->{hits}->{hits} } ){
my $f = $hit->{fields};
my $h = {};
while( my ($k, $v) = each %$f ){
# Strip '_source.' prefix from keys.
$k =~ s/^_source\.//;
$h->{ $k } = $v;
}
push @view_files, $h;
}


# TODO: make took more automatic (to include all)
$c->stash(
Expand All @@ -99,15 +112,7 @@ sub view : Private {
),
root => \@root_files,
examples => \@examples,
files => [
map {
{
%{ $_->{fields} },
module => $_->{fields}->{'_source.module'},
abstract => $_->{fields}->{'_source.abstract'}
}
} @{ $modules->{hits}->{hits} }
]
files => \@view_files,
}
);
}
Expand Down
9 changes: 8 additions & 1 deletion lib/MetaCPAN/Web/Model/API/Release.pm
Expand Up @@ -160,8 +160,15 @@ sub modules {
},
size => 999,
sort => ['documentation'],
# Get indexed and authorized from _source to work around ES bug:
# https://github.com/CPAN-API/metacpan-web/issues/881
# https://github.com/elasticsearch/elasticsearch/issues/2551
fields => [
qw(documentation _source.abstract _source.module path status author release indexed authorized)
qw(
documentation path status author release
_source.abstract _source.module
_source.indexed _source.authorized
)
],
}
);
Expand Down

0 comments on commit 08a450f

Please sign in to comment.