@@ -97,6 +97,11 @@ sub release_contributor_update_actions {
9797 return \@actions ;
9898}
9999
100+ has email_mapping => (
101+ is => ' ro' ,
102+ default => sub { {} },
103+ );
104+
100105sub get_contributors {
101106 my ( $self , $release ) = @_ ;
102107
@@ -183,24 +188,34 @@ sub get_contributors {
183188 }
184189
185190 if (%want_email ) {
186- my $check_author = $self -> es-> search(
187- es_doc_path(' author' ),
188- body => {
189- query => { terms => { email => [ sort keys %want_email ] } },
190- _source => [ ' email' , ' pauseid' ],
191- size => 100,
192- },
193- );
194-
195- for my $author ( @{ $check_author -> {hits }{hits } } ) {
196- my $emails = $author -> {_source }{email };
197- $emails = [$emails ]
198- if !ref $emails ;
199- my $pauseid = uc $author -> {_source }{pauseid };
200- for my $email (@$emails ) {
201- for my $contrib ( @{ $want_email {$email } } ) {
202- $contrib -> {pauseid } = $pauseid ;
203- }
191+ my $email_mapping = $self -> email_mapping;
192+
193+ my @fetch_email = grep !exists $email_mapping -> {$_ },
194+ sort keys %want_email ;
195+
196+ if (@fetch_email ) {
197+ my $check_author = $self -> es-> search(
198+ es_doc_path(' author' ),
199+ body => {
200+ query => { terms => { email => \@fetch_email } },
201+ _source => [ ' email' , ' pauseid' ],
202+ size => 100,
203+ },
204+ );
205+
206+ for my $author ( @{ $check_author -> {hits }{hits } } ) {
207+ my $pauseid = uc $author -> {_source }{pauseid };
208+ my $emails = $author -> {_source }{email };
209+ $email_mapping -> {$_ } //= $pauseid
210+ for ref $emails ? @$emails : $emails ;
211+ }
212+ }
213+
214+ for my $email ( keys %want_email ) {
215+ my $pauseid = $email_mapping -> {$email }
216+ or next ;
217+ for my $contrib ( @{ $want_email {$email } } ) {
218+ $contrib -> {pauseid } = $pauseid ;
204219 }
205220 }
206221 }
0 commit comments