1
0
mirror of https://github.com/funamitech/mastodon synced 2024-11-30 15:58:28 +09:00

Pull out constant from AccountWarning.recent scope (#29767)

This commit is contained in:
Matt Jankowski 2024-03-27 10:08:04 -04:00 committed by GitHub
parent 27d014a7fa
commit b016f03637
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -27,6 +27,8 @@ class AccountWarning < ApplicationRecord
suspend: 4_000, suspend: 4_000,
}, suffix: :action }, suffix: :action
RECENT_PERIOD = 3.months.freeze
normalizes :text, with: ->(text) { text.to_s }, apply_to_nil: true normalizes :text, with: ->(text) { text.to_s }, apply_to_nil: true
belongs_to :account, inverse_of: :account_warnings belongs_to :account, inverse_of: :account_warnings
@ -37,7 +39,7 @@ class AccountWarning < ApplicationRecord
scope :latest, -> { order(id: :desc) } scope :latest, -> { order(id: :desc) }
scope :custom, -> { where.not(text: '') } scope :custom, -> { where.not(text: '') }
scope :recent, -> { where('account_warnings.created_at >= ?', 3.months.ago) } scope :recent, -> { where(created_at: RECENT_PERIOD.ago..) }
def statuses def statuses
Status.with_discarded.where(id: status_ids || []) Status.with_discarded.where(id: status_ids || [])