Check if we want to send email for a build before iterating through its users

Signed-off-by: Shea Levy <shea@shealevy.com>
This commit is contained in:
Shea Levy 2013-07-05 14:06:10 -04:00
parent 117ae78a45
commit 93a14ccf32

View file

@ -52,11 +52,6 @@ sub buildFinished {
my %addresses; my %addresses;
foreach my $b ($build, @{$dependents}) { foreach my $b ($build, @{$dependents}) {
my $prevBuild = getPreviousBuild($b); my $prevBuild = getPreviousBuild($b);
my $to = $b->jobset->emailoverride ne "" ? $b->jobset->emailoverride : $b->maintainers;
foreach my $address (split ",", $to) {
$address = trim $address;
# Do we want to send mail for this build? # Do we want to send mail for this build?
unless ($ENV{'HYDRA_FORCE_SEND_MAIL'}) { unless ($ENV{'HYDRA_FORCE_SEND_MAIL'}) {
next unless $b->jobset->enableemail; next unless $b->jobset->enableemail;
@ -69,6 +64,11 @@ sub buildFinished {
next if defined $prevBuild && ($b->buildstatus == $prevBuild->buildstatus); next if defined $prevBuild && ($b->buildstatus == $prevBuild->buildstatus);
} }
my $to = $b->jobset->emailoverride ne "" ? $b->jobset->emailoverride : $b->maintainers;
foreach my $address (split ",", $to) {
$address = trim $address;
$addresses{$address} //= { builds => [] }; $addresses{$address} //= { builds => [] };
push @{$addresses{$address}->{builds}}, $b; push @{$addresses{$address}->{builds}}, $b;
} }