Skip to content

Commit

Permalink
Removed Elasticsearch::Adapter and its usage
Browse files Browse the repository at this point in the history
With all queries having switched to using API endpoints,
we no longer need the method single_valued_arrayref_to_scalar
(in WEB) and the module hosting it.
  • Loading branch information
mickeyn committed Jul 4, 2017
1 parent b2f653c commit 074686f
Show file tree
Hide file tree
Showing 4 changed files with 8 additions and 168 deletions.
89 changes: 0 additions & 89 deletions lib/MetaCPAN/Web/Elasticsearch/Adapter.pm

This file was deleted.

25 changes: 8 additions & 17 deletions lib/MetaCPAN/Web/Role/ReleaseInfo.pm
Expand Up @@ -3,9 +3,6 @@ package MetaCPAN::Web::Role::ReleaseInfo;
use Moose::Role;
use Future;

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

# TODO: are there other controllers that do (or should) include this?

# TODO: should some of this be in a separate (instantiable) model
Expand Down Expand Up @@ -62,21 +59,15 @@ sub api_requests {
# organize the api results into simple variables for the template
sub stash_api_results {
my ( $self, $c, $reqs, $data ) = @_;

my %to_stash = (
author => $reqs->{author},
distribution => $reqs->{distribution},
rating => $reqs->{rating}->{ratings}->{ $data->{distribution} },
versions => $reqs->{versions}{releases},
$c->stash(
{
author => $reqs->{author},
distribution => $reqs->{distribution},
rating => $reqs->{rating}{ratings}{ $data->{distribution} },
versions => $reqs->{versions}{releases},
contributors => $reqs->{contributors},
}
);

my %stash
= map { $_ => single_valued_arrayref_to_scalar( $to_stash{$_} ) }
( 'rating', 'distribution', 'versions' );

$stash{contributors} = $reqs->{contributors};

$c->stash( \%stash );
}

1;
58 changes: 0 additions & 58 deletions t/elasticsearch_adapter.t

This file was deleted.

4 changes: 0 additions & 4 deletions t/model/release.t
Expand Up @@ -5,9 +5,6 @@ use Test::More;
use Cpanel::JSON::XS qw( decode_json );
use MetaCPAN::Web;

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

my ( $true, $false ) = @{ decode_json('[true, false]') };

# Explicitly test that we get a boolean.
Expand All @@ -27,7 +24,6 @@ subtest modules => sub {
ok( scalar @files, 'found files with modules' );

foreach my $file (@files) {
single_valued_arrayref_to_scalar($file);

# this is a hack for the later sort check:
# 1. fix to both 'undefined value' warnings
Expand Down

0 comments on commit 074686f

Please sign in to comment.