@@ -153,6 +153,7 @@ sub get_contributors {
153153 $dupe ? () : $info ;
154154 } ( @$authors , @$contribs );
155155
156+ my %want_email ;
156157 for my $contrib (@contribs ) {
157158
158159 # heuristic to autofill pause accounts
@@ -165,20 +166,27 @@ sub get_contributors {
165166
166167 }
167168
168- # check if contributor's email points to a registered author
169- if ( !$contrib -> {pauseid } ) {
170- for my $email ( @{ $contrib -> {email } } ) {
171- my $check_author = $self -> es-> search(
172- es_doc_path(' author' ),
173- body => {
174- query => { term => { email => $email } },
175- size => 10,
176- }
177- );
169+ push @{ $want_email {$_ } }, $contrib for @{ $contrib -> {email } };
170+ }
171+
172+ if (%want_email ) {
173+ my $check_author = $self -> es-> search(
174+ es_doc_path(' author' ),
175+ body => {
176+ query => { terms => { email => [ sort keys %want_email ] } },
177+ _source => [ ' email' , ' pauseid' ],
178+ size => 100,
179+ },
180+ );
178181
179- if ( hit_total($check_author ) ) {
180- $contrib -> {pauseid }
181- = uc $check_author -> {hits }{hits }[0]{_source }{pauseid };
182+ for my $author ( @{ $check_author -> {hits }{hits } } ) {
183+ my $emails = $author -> {_source }{email };
184+ $emails = [$emails ]
185+ if !ref $emails ;
186+ my $pauseid = uc $author -> {_source }{pauseid };
187+ for my $email (@$emails ) {
188+ for my $contrib ( @{ $want_email {$email } } ) {
189+ $contrib -> {pauseid } = $pauseid ;
182190 }
183191 }
184192 }
0 commit comments