Skip to content

Commit dceb9eb

Browse files
committed
a few more type removals and wrong node setting
1 parent 5cb6cbe commit dceb9eb

File tree

3 files changed

+19
-33
lines changed

3 files changed

+19
-33
lines changed

bin/check.pl

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,8 +19,8 @@
1919
# setup
2020
my $error_count = 0;
2121
my $packages_fh = read_02packages_fh();
22-
my $es_file = MetaCPAN::ES->new( type => "file" );
23-
my $es_release = MetaCPAN::ES->new( type => "release" );
22+
my $es_file = MetaCPAN::ES->new( index => "file" );
23+
my $es_release = MetaCPAN::ES->new( index => "release" );
2424

2525
my $modules_start = 0;
2626
while ( my $line = <$packages_fh> ) {

lib/MetaCPAN/Contributor.pm

Lines changed: 16 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -7,10 +7,7 @@ use v5.36;
77
use Ref::Util qw< is_arrayref >;
88

99
use MetaCPAN::ES;
10-
use MetaCPAN::Ingest qw<
11-
config
12-
digest
13-
>;
10+
use MetaCPAN::Ingest qw< digest >;
1411

1512
use Sub::Exporter -setup => {
1613
exports => [ qw<
@@ -20,6 +17,8 @@ use Sub::Exporter -setup => {
2017
};
2118

2219
sub get_cpan_author_contributors ( $author, $release, $distribution ) {
20+
my $es_contributor = MetaCPAN::ES->new( index => 'contributor' );
21+
2322
my @ret;
2423

2524
my $data;
@@ -33,11 +32,7 @@ sub get_cpan_author_contributors ( $author, $release, $distribution ) {
3332

3433
# skip existing records
3534
my $id = digest( $d->{pauseid}, $release );
36-
my $es = MetaCPAN::ES->new(
37-
index => 'contributor',
38-
type => 'contributor'
39-
);
40-
my $exists = $es->exists( id => $id );
35+
my $exists = $es_contributor->exists( id => $id );
4136
next if $exists;
4237

4338
$d->{release_author} = $author;
@@ -54,13 +49,12 @@ sub update_release_contirbutors ( $document, $timeout = "5m" ) {
5449
@{$document}{qw< author name distribution >} );
5550
return unless $data and is_arrayref($data);
5651

57-
my $es
58-
= MetaCPAN::ES->new( index => 'contributor', type => 'contributor' );
59-
my $bulk = $es->bulk( timeout => $timeout );
52+
my $es_contributor = MetaCPAN::ES->new( index => 'contributor' );
53+
my $bulk_contributor = $es_contributor->bulk( timeout => $timeout );
6054

6155
for my $d ( @{$data} ) {
6256
my $id = digest( $d->{pauseid}, $d->{release_name} );
63-
$bulk->update( {
57+
$bulk_contributor->update( {
6458
id => $id,
6559
doc => {
6660
pauseid => $d->{pauseid},
@@ -72,13 +66,12 @@ sub update_release_contirbutors ( $document, $timeout = "5m" ) {
7266
} );
7367
}
7468

75-
$bulk->flush;
69+
$bulk_contributor->flush;
7670
}
7771

7872
sub get_contributors ( $author_name, $release_name ) {
79-
my $config = config;
80-
my $node = $config->{es_test_node};
81-
my $es = MetaCPAN::ES->new( type => "release", node => $node );
73+
my $es_release = MetaCPAN::ES->new( index => "release" );
74+
my $es_author = MetaCPAN::ES->new( index => "author" );
8275

8376
my $query = +{
8477
query => {
@@ -91,7 +84,7 @@ sub get_contributors ( $author_name, $release_name ) {
9184
}
9285
};
9386

94-
my $res = $es->search(
87+
my $res = $es_release->search(
9588
body => {
9689
query => $query,
9790
size => 999,
@@ -115,17 +108,12 @@ sub get_contributors ( $author_name, $release_name ) {
115108
}
116109
$authors = [ grep { $_ ne 'unknown' } @$authors ];
117110

111+
# TODO: check if check is still needed -
118112
# this check is against a failure in tests (because fake author)
119113
return
120-
unless $es->exists(
121-
type => 'author',
122-
id => $author_name,
123-
);
114+
unless $es_author->exists( id => $author_name );
124115

125-
my $author = $es->get(
126-
type => 'author',
127-
id => $author_name,
128-
);
116+
my $author = $es_author->get( id => $author_name );
129117

130118
my $author_email = $author->{_source}{email};
131119
my $author_gravatar_url = $author->{_source}{gravatar_url};
@@ -194,8 +182,7 @@ sub get_contributors ( $author_name, $release_name ) {
194182
}
195183

196184
if (%want_email) {
197-
my $check_author = $es->search(
198-
type => 'author',
185+
my $check_author = $es_author->search(
199186
body => {
200187
query => { term => { email => [ sort keys %want_email ] } },
201188
_source => [ 'email', 'pauseid' ],
@@ -224,8 +211,7 @@ sub get_contributors ( $author_name, $release_name ) {
224211
}
225212
};
226213

227-
my $contrib_authors = $es->search(
228-
type => 'author',
214+
my $contrib_authors = $es_author->search(
229215
body => {
230216
query => $contrib_query,
231217
size => 999,

lib/MetaCPAN/External/Debian.pm

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -74,7 +74,7 @@ sub dist_for_debian ( $source, $url ) {
7474
return $dist->dist;
7575
}
7676
elsif ( $source =~ /^lib(.*)-perl$/ ) {
77-
my $es = MetaCPAN::ES->new( type => 'release' );
77+
my $es = MetaCPAN::ES->new( index => 'release' );
7878
my $res = $es->scroll(
7979
body => {
8080
query => {

0 commit comments

Comments
 (0)