Skip to content

Commit 5d79df0

Browse files
ClearlyClaireGargron
authored andcommitted
Fix expiration date of filters being set to “Never” when editing them (#11204)
When editing a custom filter, select the shortest preset duration that still covers the remaining time of that filter. Fixes #9506
1 parent 0367ddb commit 5d79df0

1 file changed

Lines changed: 7 additions & 0 deletions

File tree

app/models/custom_filter.rb

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,13 @@ class CustomFilter < ApplicationRecord
3535
before_validation :clean_up_contexts
3636
after_commit :remove_cache
3737

38+
def expires_in
39+
return @expires_in if defined?(@expires_in)
40+
return nil if expires_at.nil?
41+
42+
[30.minutes, 1.hour, 6.hours, 12.hours, 1.day, 1.week].find { |expires_in| expires_in.from_now >= expires_at }
43+
end
44+
3845
private
3946

4047
def clean_up_contexts

0 commit comments

Comments
 (0)