Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 11 additions & 8 deletions lib/MetaCPAN/Web/Controller/Activity.pm
Original file line number Diff line number Diff line change
Expand Up @@ -43,14 +43,17 @@ sub index : Path : Args(0) {
aggregations => {
histo => {
filter => {
and => [
{
range => {
date => { from => $start->epoch . '000' }
}
},
@$q
]
bool => {
must => [
{
range => {
date =>
{ from => $start->epoch . '000' }
}
},
@$q
]
}
},
aggregations => {
entries => {
Expand Down
17 changes: 11 additions & 6 deletions lib/MetaCPAN/Web/Controller/Mirrors.pm
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ sub index : Path : Args(0) {

my $location;
my @protocols;
if ( my $q = $c->req->parameters->{q} ) {
if ( my $q = $c->req->parameters->{'q'} ) {
my @parts = split( /\s+/, $q );
foreach my $part (@parts) {
push( @protocols, $part )
Expand All @@ -25,16 +25,21 @@ sub index : Path : Args(0) {
}
}

my @or;
push( @or, { not => { filter => { missing => { field => $_ } } } } )
for (@protocols);
my @filters
= map +{ filter => { missing => { field => $_ } } },
@protocols;

my $data = $c->model('API')->request(
'/mirror/_search',
{
size => 999,
query => { match_all => {} },
@or ? ( filter => { and => \@or } ) : (),
query => (
@filters
? {
bool => { must_not => { bool => should => \@filters } }
}
: { match_all => {} }
),
$location
? (
sort => {
Expand Down
4 changes: 1 addition & 3 deletions lib/MetaCPAN/Web/Model/API/Author.pm
Original file line number Diff line number Diff line change
Expand Up @@ -98,9 +98,7 @@ sub by_user {
my $query = return $self->request(
'/author/_search',
{
query => { match_all => {} },
filter =>
{ or => [ map { { term => { user => $_ } } } @{$users} ] },
query => { terms => { user => $users } },
fields => [qw(user pauseid)],
size => 100
}
Expand Down
21 changes: 3 additions & 18 deletions lib/MetaCPAN/Web/Model/API/Favorite.pm
Original file line number Diff line number Diff line change
Expand Up @@ -26,15 +26,7 @@ sub get {
{
size => 0,
query => {
filtered => {
query => { match_all => {} },
filter => {
or => [
map { { term => { 'distribution' => $_ } } }
@distributions
]
}
}
terms => { 'distribution' => \@distributions }
},
aggregations => {
favorites => {
Expand Down Expand Up @@ -177,12 +169,7 @@ sub by_dist {
return $self->request(
'/favorite/_search',
{
query => {
filtered => {
query => { match_all => {} },
filter => { term => { distribution => $distribution }, },
}
},
query => { term => { distribution => $distribution } },
_source => "user",
size => 1000,
}
Expand All @@ -195,9 +182,7 @@ sub plusser_by_id {
return $self->request(
'/author/_search',
{
query => { match_all => {} },
filter =>
{ or => [ map { { term => { user => $_ } } } @{$users} ] },
query => { terms => { user => $users } },
_source => { includes => [qw(pauseid gravatar_url)] },
size => 1000,
sort => ['pauseid']
Expand Down
27 changes: 12 additions & 15 deletions lib/MetaCPAN/Web/Model/API/File.pm
Original file line number Diff line number Diff line change
Expand Up @@ -18,21 +18,18 @@ sub dir {
'/file/_search',
{
query => {
filtered => {
query => { match_all => {}, },
filter => {
and => [
{ term => { 'level' => scalar @path } },
{ term => { 'author' => $author } },
{ term => { 'release' => $release } },
{
prefix => {
'path' => join( q{/}, @path, q{} )
}
},
]
},
}
bool => {
must => [
{ term => { 'level' => scalar @path } },
{ term => { 'author' => $author } },
{ term => { 'release' => $release } },
{
prefix => {
'path' => join( q{/}, @path, q{} )
}
},
]
},
},
size => 999,
fields => [
Expand Down
21 changes: 8 additions & 13 deletions lib/MetaCPAN/Web/Model/API/Lab.pm
Original file line number Diff line number Diff line change
Expand Up @@ -75,24 +75,19 @@ sub _handle_module {
sub fetch_latest_distros {
my ( $self, $size, $pauseid ) = @_;

# status can have all kinds of values, cpan is an attempt to find the ones that are on cpan but
# are not authorized. Maybe it also includes ones that were superseeded by releases of other people
my @filter = ( { not => { term => { status => 'backpan' } } } );
if ($pauseid) {
push @filter, { term => { author => $pauseid } };
}

my $cv = $self->cv;
my $r = $self->request(
'/release/_search',
{
query => {
filtered => {
query => { match_all => {} },
filter => {
and => \@filter,
},
},
bool => {
must => [
{ terms => { status => [qw< cpan latest >] } },
(
$pauseid ? { term => { author => $pauseid } } : ()
),
],
}
},
sort => [
'distribution', { 'version_numified' => { reverse => 1 } }
Expand Down
21 changes: 9 additions & 12 deletions lib/MetaCPAN/Web/Model/API/Module.pm
Original file line number Diff line number Diff line change
Expand Up @@ -85,19 +85,16 @@ sub requires {
'/release/_search',
{
query => {
filtered => {
query => { 'match_all' => {} },
filter => {
and => [
{ term => { 'status' => 'latest' } },
{ term => { 'authorized' => 1 } },
{
term => {
'dependency.module' => $module
}
bool => {
must => [
{ term => { 'status' => 'latest' } },
{ term => { 'authorized' => 1 } },
{
term => {
'dependency.module' => $module
}
]
}
}
]
}
},
size => $page_size,
Expand Down
10 changes: 1 addition & 9 deletions lib/MetaCPAN/Web/Model/API/Rating.pm
Original file line number Diff line number Diff line change
Expand Up @@ -42,15 +42,7 @@ sub get {
{
size => 0,
query => {
filtered => {
query => { match_all => {} },
filter => {
or => [
map { { term => { 'distribution' => $_ } } }
@distributions
]
}
}
terms => { distribution => \@distributions }
},
aggregations => {
ratings => {
Expand Down
Loading