Skip to content

Commit

Permalink
Merge pull request #625 from metacpan/mickey/api_cleanups
Browse files Browse the repository at this point in the history
api cleanups
  • Loading branch information
oalders committed May 8, 2017
2 parents c249022 + cd7d998 commit fe3352c
Show file tree
Hide file tree
Showing 5 changed files with 41 additions and 69 deletions.
20 changes: 6 additions & 14 deletions lib/MetaCPAN/Document/File.pm
Expand Up @@ -74,14 +74,10 @@ sub _build_section {
has abstract => (
required => 1,
is => 'ro',

# isa is commented as it affect the type mapping
# see https://github.com/metacpan/metacpan-api/pull/484
# -- Mickey
# isa => Maybe[Str],
lazy => 1,
builder => '_build_abstract',
index => 'analyzed',
isa => Maybe [Str],
lazy => 1,
builder => '_build_abstract',
index => 'analyzed',
);

sub _build_abstract {
Expand Down Expand Up @@ -300,12 +296,8 @@ set to C<undef>.
=cut

has documentation => (
is => 'ro',

# isa is commented as it affect the type mapping
# see https://github.com/metacpan/metacpan-api/pull/484
# -- Mickey
# isa => Maybe [Str],
is => 'ro',
isa => Maybe [Str],
lazy => 1,
index => 'analyzed',
builder => '_build_documentation',
Expand Down
46 changes: 24 additions & 22 deletions lib/MetaCPAN/Document/Release.pm
Expand Up @@ -313,13 +313,7 @@ sub aggregate_status_by_author {

sub find_depending_on {
my ( $self, $modules ) = @_;
return $self->filter(
{
or => [
map { { term => { 'dependency.module' => $_ } } } @$modules
]
}
);
return $self->filter( { terms => { 'dependency.module' => $modules } } );
}

sub find {
Expand Down Expand Up @@ -347,21 +341,29 @@ sub predecessor {
}

sub find_github_based {
my $or = [

# { prefix => { "resources.homepage" => 'http://github.com/' } },
# { prefix => { "resources.homepage" => 'https://github.com/' } },
# { prefix => { "resources.repository.web" => 'http://github.com/' } },
# { prefix => { "resources.repository.web" => 'https://github.com/' } },
# { prefix => { "resources.repository.url" => 'http://github.com/' } },
# { prefix => { "resources.repository.url" => 'https://github.com/' } },
# { prefix => { "resources.repository.url" => 'git://github.com/' } },
{ prefix => { "resources.bugtracker.web" => 'http://github.com/' } },
{ prefix => { "resources.bugtracker.web" => 'https://github.com/' } },
];
shift #->fields([qw(resources)])
->filter(
{ and => [ { term => { status => 'latest' } }, { or => $or } ] } );
shift->filter(
{
and => [
{ term => { status => 'latest' } },
{
or => [
{
prefix => {
"resources.bugtracker.web" =>
'http://github.com/'
}
},
{
prefix => {
"resources.bugtracker.web" =>
'https://github.com/'
}
},
]
}
]
}
);
}

__PACKAGE__->meta->make_immutable;
Expand Down
34 changes: 10 additions & 24 deletions lib/MetaCPAN/Model/Search.pm
Expand Up @@ -32,9 +32,11 @@ my @ROGUE_DISTRIBUTIONS
= qw(kurila perl_debug perl_mlb perl-5.005_02+apache1.3.3+modperl pod2texi perlbench spodcxx Bundle-Everything);

sub _not_rogue {
my @rogue_dists
= map { { term => { 'distribution' => $_ } } } @ROGUE_DISTRIBUTIONS;
return { not => { filter => { or => \@rogue_dists } } };
return {
not => {
filter => { terms => { distribution => \@ROGUE_DISTRIBUTIONS } }
}
};
}

sub search_simple {
Expand Down Expand Up @@ -168,17 +170,8 @@ sub _search_collapsed {
size => 5000,
query => {
filtered => {
filter => {
and => [
{
or => [
map {
{ term => { 'distribution' => $_ } }
} @distributions
]
}
]
}
filter =>
{ terms => { 'distribution' => \@distributions } }
}
}
}
Expand Down Expand Up @@ -383,9 +376,7 @@ sub _build_search_descriptions_query {
query => {
filtered => {
query => { match_all => {} },
filter => {
or => [ map { { term => { id => $_ } } } @ids ]
}
filter => { terms => { id => \@ids } },
}
},
fields => [qw(description id)],
Expand Down Expand Up @@ -418,13 +409,8 @@ sub _build_search_favorites_query {
size => 0,
query => {
filtered => {
query => { match_all => {} },
filter => {
or => [
map { { term => { 'distribution' => $_ } } }
@distributions
]
}
query => { match_all => {} },
filter => { terms => { distribution => \@distributions } },
}
},
aggregations => {
Expand Down
2 changes: 0 additions & 2 deletions lib/MetaCPAN/Script/Watcher.pm
Expand Up @@ -29,8 +29,6 @@ my $latest = 0;

my @segments = qw(1h 6h 1d 1W 1M 1Q 1Y Z);

#my @segments = qw(1Y);

sub run {
my $self = shift;
while (1) {
Expand Down
8 changes: 1 addition & 7 deletions lib/MetaCPAN/Server/Controller/Changes.pm
Expand Up @@ -62,13 +62,7 @@ sub get : Chained('index') : PathPart('') : Args(2) {
and => [
{ term => { level => 0 } },
{ term => { directory => 0 } },
{
or => [
map {
{ term => { 'name' => $_ } }
} @candidates
]
}
{ terms => { name => \@candidates } },
]
}
],
Expand Down

0 comments on commit fe3352c

Please sign in to comment.