Skip to content

Commit

Permalink
Activity: fix query terms
Browse files Browse the repository at this point in the history
A quick fix to terms that are currently not matching anything.
Next, these queries will be moved to the API.
  • Loading branch information
mickeyn committed May 27, 2017
1 parent 5d34c8e commit 700c7c8
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 24 deletions.
12 changes: 4 additions & 8 deletions lib/MetaCPAN/Web/Controller/Activity.pm
Expand Up @@ -21,16 +21,12 @@ sub index : Path : Args(0) {
push( @$q, { term => { distribution => $distribution } } );
}
if ( my $requires = $req->parameters->{requires} ) {
push( @$q, { term => { 'release.dependency.module' => $requires } } );
push( @$q, { term => { 'dependency.module' => $requires } } );
}
if ( $req->parameters->{f} && $req->parameters->{f} eq 'n' ) {
push(
@$q,
@{
$c->model('API::Release')
->_new_distributions_query->{constant_score}->{filter}
->{and}
}
push( @$q,
{ term => { first => 1 } },
{ terms => { status => [qw< cpan latest >] } },
);
}

Expand Down
28 changes: 12 additions & 16 deletions lib/MetaCPAN/Web/Model/API/Release.pm
Expand Up @@ -48,21 +48,6 @@ sub distribution {
$self->request("/distribution/$dist");
}

sub _new_distributions_query {
return {
constant_score => {
filter => {
bool => {
must => [
{ term => { first => 1 } },
{ terms => { status => [qw< cpan latest >] } },
]
}
}
}
};
}

sub latest_by_author {
my ( $self, $author ) = @_;
return $self->request(
Expand Down Expand Up @@ -106,7 +91,18 @@ sub recent {
my ( $self, $page, $page_size, $type ) = @_;
my $query;
if ( $type eq 'n' ) {
$query = $self->_new_distributions_query;
$query = {
constant_score => {
filter => {
bool => {
must => [
{ term => { first => 1 } },
{ terms => { status => [qw< cpan latest >] } },
]
}
}
}
};
}
elsif ( $type eq 'a' ) {
$query = { match_all => {} };
Expand Down

0 comments on commit 700c7c8

Please sign in to comment.