@@ -7,10 +7,7 @@ use v5.36;
77use Ref::Util qw< is_arrayref > ;
88
99use MetaCPAN::ES;
10- use MetaCPAN::Ingest qw<
11- config
12- digest
13- > ;
10+ use MetaCPAN::Ingest qw< digest > ;
1411
1512use Sub::Exporter -setup => {
1613 exports => [ qw<
@@ -20,6 +17,8 @@ use Sub::Exporter -setup => {
2017};
2118
2219sub 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
7872sub 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,
0 commit comments