Skip to content

Commit

Permalink
use query methods via ESQuery rather than the delegated model methods
Browse files Browse the repository at this point in the history
  • Loading branch information
haarg committed Jan 14, 2025
1 parent e4f72f4 commit a35c371
Show file tree
Hide file tree
Showing 29 changed files with 91 additions and 357 deletions.
23 changes: 0 additions & 23 deletions lib/MetaCPAN/Document/Author/Set.pm

This file was deleted.

27 changes: 0 additions & 27 deletions lib/MetaCPAN/Document/CVE/Set.pm

This file was deleted.

23 changes: 0 additions & 23 deletions lib/MetaCPAN/Document/Contributor/Set.pm

This file was deleted.

23 changes: 0 additions & 23 deletions lib/MetaCPAN/Document/Cover/Set.pm

This file was deleted.

23 changes: 0 additions & 23 deletions lib/MetaCPAN/Document/Distribution/Set.pm

This file was deleted.

27 changes: 0 additions & 27 deletions lib/MetaCPAN/Document/Favorite/Set.pm

This file was deleted.

31 changes: 0 additions & 31 deletions lib/MetaCPAN/Document/File/Set.pm
Original file line number Diff line number Diff line change
Expand Up @@ -11,24 +11,6 @@ use MetaCPAN::Util qw( true false );

extends 'ElasticSearchX::Model::Document::Set';

has query_file => (
is => 'ro',
isa => 'MetaCPAN::Query::File',
lazy => 1,
builder => '_build_query_file',
handles => [ qw(
dir
find_changes_files
interesting_files
files_by_category
) ],
);

sub _build_query_file {
my $self = shift;
return MetaCPAN::Query::File->new( es => $self->es );
}

has query_favorite => (
is => 'ro',
isa => 'MetaCPAN::Query::Favorite',
Expand All @@ -42,19 +24,6 @@ sub _build_query_favorite {
return MetaCPAN::Query::Favorite->new( es => $self->es );
}

has query_release => (
is => 'ro',
isa => 'MetaCPAN::Query::Release',
lazy => 1,
builder => '_build_query_release',
handles => [qw< find_download_url >],
);

sub _build_query_release {
my $self = shift;
return MetaCPAN::Query::Release->new( es => $self->es );
}

my @ROGUE_DISTRIBUTIONS = qw(
Acme-DependOnEverything
Bundle-Everything
Expand Down
23 changes: 0 additions & 23 deletions lib/MetaCPAN/Document/Mirror/Set.pm

This file was deleted.

23 changes: 0 additions & 23 deletions lib/MetaCPAN/Document/Package/Set.pm

This file was deleted.

23 changes: 0 additions & 23 deletions lib/MetaCPAN/Document/Permission/Set.pm

This file was deleted.

42 changes: 0 additions & 42 deletions lib/MetaCPAN/Document/Release/Set.pm

This file was deleted.

2 changes: 1 addition & 1 deletion lib/MetaCPAN/Server/Controller/Activity.pm
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ sub get : Path('') : Args(0) {
my ( $self, $c ) = @_;

$c->stash_or_detach(
$c->model('ESModel')->doc('release')->activity( $c->req->params ) );
$c->model('ESQuery')->release->activity( $c->req->params ) );
}

__PACKAGE__->meta->make_immutable;
Expand Down
20 changes: 12 additions & 8 deletions lib/MetaCPAN/Server/Controller/Author.pm
Original file line number Diff line number Diff line change
Expand Up @@ -16,33 +16,34 @@ sub get : Path('') : Args(1) {
$c->cdn_max_age('1y');
my $file = $self->model($c)->raw->get($id);
$c->stash_or_detach(
$c->model('ESModel')->doc('release')->author_status( $id, $file ) );
$c->model('ESQuery')->release->author_status( $id, $file ) );
}

# /author/search?q=QUERY
sub qsearch : Path('search') : Args(0) {
my ( $self, $c ) = @_;
$c->stash_or_detach(
$self->model($c)->search( @{ $c->req->params }{qw( q from )} ) );
$c->stash_or_detach( $c->model('ESQuery')
->author->search( @{ $c->req->params }{qw( q from )} ) );
}

# /author/by_ids?id=PAUSE_ID1&id=PAUSE_ID2...
sub by_ids : Path('by_ids') : Args(0) {
my ( $self, $c ) = @_;
$c->stash_or_detach( $self->model($c)->by_ids( $c->read_param('id') ) );
$c->stash_or_detach(
$c->model('ESQuery')->author->by_ids( $c->read_param('id') ) );
}

# /author/by_user/USER_ID
sub by_user : Path('by_user') : Args(1) {
my ( $self, $c, $user ) = @_;
$c->stash_or_detach( $self->model($c)->by_user($user) );
$c->stash_or_detach( $c->model('ESQuery')->author->by_user($user) );
}

# /author/by_user?user=USER_ID1&user=USER_ID2...
sub by_users : Path('by_user') : Args(0) {
my ( $self, $c ) = @_;
$c->stash_or_detach(
$self->model($c)->by_user( $c->read_param('user') ) );
$c->model('ESQuery')->author->by_user( $c->read_param('user') ) );
}

# /author/by_prefix/PAUSE_ID_PREFIX
Expand All @@ -51,8 +52,11 @@ sub by_prefix : Path('by_prefix') : Args(1) {
my $size = $c->req->param('size') // 500;
my $from = $c->req->param('from') // 0;

$c->stash_or_detach( $self->model($c)
->prefix_search( $prefix, { size => $size, from => $from } ) );
$c->stash_or_detach(
$c->model('ESQuery')->author->prefix_search(
$prefix, { size => $size, from => $from }
)
);
}

1;
Loading

0 comments on commit a35c371

Please sign in to comment.