Skip to content

Commit 2f5b7d1

Browse files
committed
find ESXM types via model rather than index
Rather than using the same index to find other types, find them via the model. This means the types don't need to be in the same index.
1 parent a2e9202 commit 2f5b7d1

26 files changed

+54
-77
lines changed

lib/MetaCPAN/Document/Distribution.pm

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@ has river => (
4040

4141
sub releases {
4242
my $self = shift;
43-
return $self->index->type("release")
43+
return $self->index->model->doc("release")
4444
->query( { term => { "distribution" => $self->name } } );
4545
}
4646

lib/MetaCPAN/Document/Release.pm

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -278,7 +278,7 @@ sub _build_download_url {
278278

279279
sub set_first {
280280
my $self = shift;
281-
my $is_first = $self->index->type('release')->query( {
281+
my $is_first = $self->index->model->doc('release')->query( {
282282
bool => {
283283
must => [
284284
{ term => { distribution => $self->distribution } },

lib/MetaCPAN/Model/Release.pm

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -84,7 +84,7 @@ has date => (
8484
},
8585
);
8686

87-
has index => ( is => 'ro' );
87+
has model => ( is => 'ro' );
8888

8989
has metadata => (
9090
is => 'ro',
@@ -222,8 +222,7 @@ sub _build_document {
222222
|| $document->{abstract} eq 'null' );
223223

224224
$document
225-
= $self->index->type('release')
226-
->put( $document, { refresh => true } );
225+
= $self->model->doc('release')->put( $document, { refresh => true } );
227226

228227
# create distribution if doesn't exist
229228
my $dist_count = $self->es->count(
@@ -232,7 +231,7 @@ sub _build_document {
232231
body => { query => { term => { name => $self->distribution } } },
233232
);
234233
if ( !$dist_count->{count} ) {
235-
$self->index->type('distribution')
234+
$self->model->doc('distribution')
236235
->put( { name => $self->distribution }, { create => 1 } );
237236
}
238237
return $document;
@@ -333,7 +332,7 @@ sub _build_files {
333332

334333
my @files;
335334
log_debug { 'Indexing ', scalar @{ $self->archive->files }, ' files' };
336-
my $file_set = $self->index->type('file');
335+
my $file_set = $self->model->doc('file');
337336

338337
my $extract_dir = $self->extract;
339338
File::Find::find(

lib/MetaCPAN/Model/User/Account.pm

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -121,8 +121,8 @@ after add_identity => sub {
121121
my ( $self, $identity ) = @_;
122122
if ( $identity->{name} eq 'pause' ) {
123123
$self->clear_looks_human;
124-
my $profile = $self->index->model->index('cpan')->type('author')
125-
->get( $identity->{key} );
124+
my $profile
125+
= $self->index->model->doc('author')->get( $identity->{key} );
126126

127127
# Not every user is an author
128128
if ($profile) {
@@ -157,8 +157,7 @@ sub remove_identity {
157157
@$ids = grep { $_->{name} ne $identity } @$ids;
158158

159159
if ( $identity eq 'pause' ) {
160-
my $profile = $self->index->model->index('cpan')->type('author')
161-
->get( $id->{key} );
160+
my $profile = $self->index->model->doc('author')->get( $id->{key} );
162161

163162
if ( $profile && $profile->user eq $self->id ) {
164163
$profile->_clear_user;

lib/MetaCPAN/Script/First.pm

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ has distribution => (
1717

1818
sub run {
1919
my $self = shift;
20-
my $distributions = $self->index->type("distribution");
20+
my $distributions = $self->model->doc("distribution");
2121
$distributions
2222
= $distributions->query( { term => { name => $self->distribution } } )
2323
if $self->distribution;

lib/MetaCPAN/Script/Latest.pm

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -263,7 +263,7 @@ sub reindex {
263263
my ( $self, $bulk, $source, $status ) = @_;
264264

265265
# Update the status on the release.
266-
my $release = $self->index->type('release')->get( {
266+
my $release = $self->model->doc('release')->get( {
267267
author => $source->{author},
268268
name => $source->{release},
269269
} );

lib/MetaCPAN/Script/Mirrors.pm

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ sub index_mirrors {
2020
log_info { 'Getting mirrors.json file from ' . $self->cpan };
2121

2222
my $json = $self->cpan->child( 'indices', 'mirrors.json' )->slurp;
23-
my $type = $self->index->type('mirror');
23+
my $type = $self->model->doc('mirror');
2424

2525
# Clear out everything in the index
2626
# so don't end up with old mirrors

lib/MetaCPAN/Script/Release.pm

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -270,7 +270,7 @@ sub _get_release_model {
270270
bulk => $bulk,
271271
distinfo => $d,
272272
file => $archive_path,
273-
index => $self->index,
273+
model => $self->model,
274274
level => $self->level,
275275
logger => $self->logger,
276276
status => $self->detect_status( $d->cpanid, $d->filename ),
@@ -285,7 +285,7 @@ sub import_archive {
285285
my $self = shift;
286286
my $archive_path = shift;
287287

288-
my $bulk = $self->index->bulk( size => $self->_bulk_size );
288+
my $bulk = $self->model->bulk( size => $self->_bulk_size );
289289
my $model = $self->_get_release_model( $archive_path, $bulk );
290290

291291
log_debug {'Gathering modules'};

lib/MetaCPAN/Script/Role/Contributor.pm

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ sub get_cpan_author_contributors {
1010
my @ret;
1111
my $es = $self->es;
1212

13-
my $type = $self->index->type('release');
13+
my $type = $self->model->doc('release');
1414
my $data;
1515
eval {
1616
$data = $type->get_contributors( $author, $release );

lib/MetaCPAN/Script/Role/External/Debian.pm

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -98,7 +98,7 @@ sub dist_for_debian {
9898
my $query
9999
= { term => { 'distribution.lowercase' => $alias{$1} // $1 } };
100100

101-
my $res = $self->index->type('release')->query($query)
101+
my $res = $self->model->doc('release')->query($query)
102102
->sort( [ { date => { order => "desc" } } ] )->raw->first;
103103

104104
return $res->{_source}{distribution}

0 commit comments

Comments
 (0)