Add method to get the archived proposals date limit

This commit is contained in:
Javi Martín
2023-07-19 16:34:43 +02:00
parent 8898c30f55
commit 243d55ec82
5 changed files with 12 additions and 10 deletions

View File

@@ -72,8 +72,8 @@ class Proposal < ApplicationRecord
scope :sort_by_flags, -> { order(flags_count: :desc, updated_at: :desc) }
scope :sort_by_archival_date, -> { archived.sort_by_confidence_score }
scope :sort_by_recommendations, -> { order(cached_votes_up: :desc) }
scope :archived, -> { where("proposals.created_at <= ?", Setting["months_to_archive_proposals"].to_i.months.ago) }
scope :not_archived, -> { where("proposals.created_at > ?", Setting["months_to_archive_proposals"].to_i.months.ago) }
scope :archived, -> { where("proposals.created_at <= ?", Setting.archived_proposals_date_limit) }
scope :not_archived, -> { where("proposals.created_at > ?", Setting.archived_proposals_date_limit) }
scope :last_week, -> { where("proposals.created_at >= ?", 7.days.ago) }
scope :retired, -> { where.not(retired_at: nil) }
scope :not_retired, -> { where(retired_at: nil) }
@@ -221,7 +221,7 @@ class Proposal < ApplicationRecord
end
def archived?
created_at <= Setting["months_to_archive_proposals"].to_i.months.ago
created_at <= Setting.archived_proposals_date_limit
end
def notifications