From 971c5348b0c45a91e93f1ddf99cbb8e6c7ef6e27 Mon Sep 17 00:00:00 2001 From: Mickey Nasriachi Date: Wed, 5 Jul 2017 14:27:41 +0100 Subject: [PATCH] Removed code used to clean ES output which we no longer have --- lib/MetaCPAN/Web/Model/API.pm | 49 +---------------------------------- 1 file changed, 1 insertion(+), 48 deletions(-) diff --git a/lib/MetaCPAN/Web/Model/API.pm b/lib/MetaCPAN/Web/Model/API.pm index 7705f5f9c0..558da385c8 100644 --- a/lib/MetaCPAN/Web/Model/API.pm +++ b/lib/MetaCPAN/Web/Model/API.pm @@ -104,7 +104,7 @@ sub request { if ( $content_type =~ /^application\/json/ ) { my $out; - eval { $out = $self->process_json_response($data); }; + eval { $out = decode_json($data); }; return $out if $out; } @@ -115,53 +115,6 @@ sub request { ); } -sub process_json_response { - my ( $self, $data ) = @_; - - # Let json error propagate. - my $json = decode_json($data); - - $self->_strip_source_prefix_from_fields($json); - - return $json; -} - -sub _strip_source_prefix_from_fields { - my ( $self, $json ) = @_; - - # There appears to be a bug in older (than 0.90) ES versions where - # "A stored boolean field is being returned as a string, not as a boolean" - # when requested via "fields". To work around this we can specify - # "_source.blah" in "fields", then we strip the "_source." prefix here. - # https://github.com/metacpan/metacpan-web/issues/881 - # https://github.com/elasticsearch/elasticsearch/issues/2551 - # See .../API/Release.pm for examples of this. - - # Don't autovivify. - if ( exists( $json->{hits} ) && exists( $json->{hits}->{hits} ) ) { - foreach my $hit ( @{ $json->{hits}->{hits} } ) { - - next unless exists $hit->{fields}; - - my $fields = $hit->{fields}; - foreach my $orig ( keys %$fields ) { - my $key = $orig; # copy - - # Strip '_source.' prefix from keys. - if ( $key =~ s/^_source\.// ) { - warn "Field $key overwritten with $orig in ${\ref $self}" - if exists $fields->{$key}; - - # Update original reference. - $fields->{$key} = delete $fields->{$orig}; - } - } - } - } - - # No return, reference is modified. -} - # cache these my $encoding = Encode::find_encoding('utf-8-strict') or warn 'UTF-8 Encoding object not found';