@@ -177,6 +177,7 @@ sub get_contributors ( $author_name, $release_name ) {
177177 $dupe ? () : $info ;
178178 } ( @$authors , @$contribs );
179179
180+ my %want_email ;
180181 for my $contrib (@contribs ) {
181182
182183 # heuristic to autofill pause accounts
@@ -189,20 +190,26 @@ sub get_contributors ( $author_name, $release_name ) {
189190
190191 }
191192
192- # check if contributor's email points to a registered author
193- if ( !$contrib -> {pauseid } ) {
194- for my $email ( @{ $contrib -> {email } } ) {
195- my $check_author = $es -> search(
196- type => ' author' ,
197- body => {
198- query => { term => { email => $email } },
199- size => 10,
200- }
201- );
202-
203- if ( $check_author -> {hits }{total } ) {
204- $contrib -> {pauseid }
205- = uc $check_author -> {hits }{hits }[0]{_source }{pauseid };
193+ push @{ $want_email {$_ } }, $contrib for @{ $contrib -> {email } };
194+ }
195+
196+ if (%want_email ) {
197+ my $check_author = $es -> search(
198+ type => ' author' ,
199+ body => {
200+ query => { term => { email => [ sort keys %want_email ] } },
201+ _source => [ ' email' , ' pauseid' ],
202+ size => 10,
203+ }
204+ );
205+
206+ for my $author ( @{ $check_author -> {hits }{hits } } ) {
207+ my $emails = $author -> {_source }{email };
208+ $emails = [$emails ] if !ref $emails ;
209+ my $pauseid = uc $author -> {_source }{pauseid };
210+ for my $email (@$emails ) {
211+ for my $contrib ( @{ $want_email {$email } } ) {
212+ $contrib -> {pauseid } = $pauseid ;
206213 }
207214 }
208215 }
0 commit comments