summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMatt Jankowski <matt@jankowski.online>2024-04-29 05:01:46 -0400
committerGitHub <noreply@github.com>2024-04-29 09:01:46 +0000
commitf0c9cbaf3b079700b8179222d409c644dfd8ff66 (patch)
treef023613695f4fdd5f9c512be4547d45ffb655509
parent4527e012daa61dc07258eaedf3e03179b59fca8d (diff)
Use `EXPIRATION_DURATIONS` constant in `CustomFilter` class (#30088)
-rw-r--r--app/models/custom_filter.rb4
-rw-r--r--app/views/filters/_filter_fields.html.haml2
2 files changed, 4 insertions, 2 deletions
diff --git a/app/models/custom_filter.rb b/app/models/custom_filter.rb
index 2d8f5b6cba8..94fadc70022 100644
--- a/app/models/custom_filter.rb
+++ b/app/models/custom_filter.rb
@@ -28,6 +28,8 @@ class CustomFilter < ApplicationRecord
account
).freeze
+ EXPIRATION_DURATIONS = [30.minutes, 1.hour, 6.hours, 12.hours, 1.day, 1.week].freeze
+
include Expireable
include Redisable
@@ -52,7 +54,7 @@ class CustomFilter < ApplicationRecord
return @expires_in if defined?(@expires_in)
return nil if expires_at.nil?
- [30.minutes, 1.hour, 6.hours, 12.hours, 1.day, 1.week].find { |expires_in| expires_in.from_now >= expires_at }
+ EXPIRATION_DURATIONS.find { |expires_in| expires_in.from_now >= expires_at }
end
def irreversible=(value)
diff --git a/app/views/filters/_filter_fields.html.haml b/app/views/filters/_filter_fields.html.haml
index 5b297a6a9eb..0f4049ffb61 100644
--- a/app/views/filters/_filter_fields.html.haml
+++ b/app/views/filters/_filter_fields.html.haml
@@ -6,7 +6,7 @@
wrapper: :with_label
.fields-row__column.fields-row__column-6.fields-group
= f.input :expires_in,
- collection: [30.minutes, 1.hour, 6.hours, 12.hours, 1.day, 1.week].map(&:to_i),
+ collection: CustomFilter::EXPIRATION_DURATIONS.map(&:to_i),
include_blank: I18n.t('invites.expires_in_prompt'),
label_method: ->(i) { I18n.t("invites.expires_in.#{i}") },
wrapper: :with_label