From 1c1f5442f9c10482479596c202522994a523c75a Mon Sep 17 00:00:00 2001 From: Florian Pritz Date: Sun, 6 Jan 2019 11:22:09 +0100 Subject: Use hash to track out of sync mirrors Signed-off-by: Florian Pritz --- bin/generate-mirror-mail.pl | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/bin/generate-mirror-mail.pl b/bin/generate-mirror-mail.pl index d1fe6df..353c7b0 100755 --- a/bin/generate-mirror-mail.pl +++ b/bin/generate-mirror-mail.pl @@ -156,7 +156,7 @@ while () { die "Admin email not set in mirror json. Login problem?" unless defined $json->{admin_email}; } - my @out_of_sync; + my $issues; my @connection_failed; for my $mirror (@{$json->{urls}}) { @@ -164,7 +164,7 @@ while () { if ($mirror->{last_sync}) { my $time = str2time($mirror->{last_sync}); if ($time < time() - 60*60*24*3) { - push @out_of_sync, { + push @{$issues->{out_of_sync}}, { time => $time, url => $mirror->{url}, details_link => $mirror->{details}, @@ -181,7 +181,7 @@ while () { } # extract and deduplicate sync times - my @last_sync = keys %{{ map { ${$_}{time} => 1 } @out_of_sync }}; + my @last_sync = keys %{{ map { ${$_}{time} => 1 } @{$issues->{out_of_sync}} }}; my $sent_mail = 0; my $to = $json->{admin_email}; @@ -190,7 +190,7 @@ while () { my %values = ( out_of_sync => { last_sync => join(", ", map {time2str("%Y-%m-%d", $_)} @last_sync), - mirror_urls => join("\n", map {${$_}{details_link}} @out_of_sync), + mirror_urls => join("\n", map {${$_}{details_link}} @{$issues->{out_of_sync}}), }, connection_failed => { mirror_urls => join("\n", map {${$_}{details_link}} @connection_failed), @@ -207,10 +207,10 @@ while () { } - if (@out_of_sync and @connection_failed) { + if (@{$issues->{out_of_sync}} and @connection_failed) { send_template_mail($to, $templates{"multiple-issues"}{"subject"}, $templates{"multiple-issues"}{"template"}, \%values); $sent_mail = 1; - } elsif (@out_of_sync) { + } elsif (@{$issues->{out_of_sync}}) { send_template_mail($to, $templates{"out-of-sync"}{"subject"}, $templates{"out-of-sync"}{"template"}, \%values); $sent_mail = 1; } elsif (@connection_failed) { -- cgit v1.2.3-24-g4f1b