From 1bef772764fc1250be63e7844e97227fabf6f17b Mon Sep 17 00:00:00 2001 From: Claire Date: Thu, 1 Dec 2022 10:32:10 +0100 Subject: [PATCH 1/2] Fix some performance issues with /admin/instances (#21907) /admin/instances?availability=failing remains wholly unefficient --- app/controllers/admin/instances_controller.rb | 2 +- app/lib/delivery_failure_tracker.rb | 9 +++++++-- 2 files changed, 8 insertions(+), 3 deletions(-) diff --git a/app/controllers/admin/instances_controller.rb b/app/controllers/admin/instances_controller.rb index 5c82331dea..7c44e88b7b 100644 --- a/app/controllers/admin/instances_controller.rb +++ b/app/controllers/admin/instances_controller.rb @@ -57,7 +57,7 @@ module Admin end def preload_delivery_failures! - warning_domains_map = DeliveryFailureTracker.warning_domains_map + warning_domains_map = DeliveryFailureTracker.warning_domains_map(@instances.map(&:domain)) @instances.each do |instance| instance.failure_days = warning_domains_map[instance.domain] diff --git a/app/lib/delivery_failure_tracker.rb b/app/lib/delivery_failure_tracker.rb index 7c4e28eb79..66c1fd8c00 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 From c02dfc99f919f29957656a2b83da62fafaaefaa4 Mon Sep 17 00:00:00 2001 From: Nick Schonning Date: Thu, 1 Dec 2022 04:49:25 -0500 Subject: [PATCH 2/2] Fix GitHub form label type (#21833) --- .github/ISSUE_TEMPLATE/1.bug_report.yml | 2 +- .github/ISSUE_TEMPLATE/2.feature_request.yml | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/ISSUE_TEMPLATE/1.bug_report.yml b/.github/ISSUE_TEMPLATE/1.bug_report.yml index cdd08d2b0d..eb70896d74 100644 --- a/.github/ISSUE_TEMPLATE/1.bug_report.yml +++ b/.github/ISSUE_TEMPLATE/1.bug_report.yml @@ -1,6 +1,6 @@ name: Bug Report description: If something isn't working as expected -labels: bug +labels: [bug] body: - type: markdown attributes: diff --git a/.github/ISSUE_TEMPLATE/2.feature_request.yml b/.github/ISSUE_TEMPLATE/2.feature_request.yml index 6626c2876f..2cabcf61e0 100644 --- a/.github/ISSUE_TEMPLATE/2.feature_request.yml +++ b/.github/ISSUE_TEMPLATE/2.feature_request.yml @@ -1,6 +1,6 @@ name: Feature Request description: I have a suggestion -labels: suggestion +labels: [suggestion] body: - type: markdown attributes: