FEATURE: auto remove user status after predefined period (#17236)

This commit is contained in:
Andrei Prigorshnev
2022-07-05 19:12:22 +04:00
committed by GitHub
parent 4acf2394e6
commit c59f1729a6
27 changed files with 423 additions and 52 deletions

View File

@ -6,6 +6,10 @@ class UserStatus < ActiveRecord::Base
validate :ends_at_greater_than_set_at,
if: Proc.new { |t| t.will_save_change_to_set_at? || t.will_save_change_to_ends_at? }
def expired?
ends_at && ends_at < Time.zone.now
end
def ends_at_greater_than_set_at
if ends_at && set_at > ends_at
errors.add(:ends_at, I18n.t("user_status.errors.ends_at_should_be_greater_than_set_at"))