about summary refs log tree commit diff
path: root/app/lib
diff options
context:
space:
mode:
authorClaire <claire.github-309c@sitedethib.com>2022-12-01 11:08:52 +0100
committerClaire <claire.github-309c@sitedethib.com>2022-12-01 11:08:52 +0100
commitfd6f9bf7a75c75ad53c41b4ef0cd059bc5fbf8fc (patch)
treedb438413737f1abf14812e57a65eb9020e74cf7e /app/lib
parentfc0e11abdb80a9b24fe3ed0a29d0736cc5bfd977 (diff)
parent491ab8de89017d4dc223f98ae57bbdc23a6fd944 (diff)
Merge branch 'main' into glitch-soc/merge-upstream
Diffstat (limited to 'app/lib')
-rw-r--r--app/lib/delivery_failure_tracker.rb9
1 files changed, 7 insertions, 2 deletions
diff --git a/app/lib/delivery_failure_tracker.rb b/app/lib/delivery_failure_tracker.rb
index 7c4e28eb7..66c1fd8c0 100644
--- a/app/lib/delivery_failure_tracker.rb
+++ b/app/lib/delivery_failure_tracker.rb
@@ -65,8 +65,13 @@ class DeliveryFailureTracker
       domains - UnavailableDomain.all.pluck(:domain)
     end
 
-    def warning_domains_map
-      warning_domains.index_with { |domain| redis.scard(exhausted_deliveries_key_by(domain)) }
+    def warning_domains_map(domains = nil)
+      if domains.nil?
+        warning_domains.index_with { |domain| redis.scard(exhausted_deliveries_key_by(domain)) }
+      else
+        domains -= UnavailableDomain.where(domain: domains).pluck(:domain)
+        domains.index_with { |domain| redis.scard(exhausted_deliveries_key_by(domain)) }.filter { |_, days| days.positive? }
+      end
     end
 
     private