diff --git a/app/controllers/proposals_controller.rb b/app/controllers/proposals_controller.rb index 578395ab3..1bfed0aa9 100644 --- a/app/controllers/proposals_controller.rb +++ b/app/controllers/proposals_controller.rb @@ -12,7 +12,7 @@ class ProposalsController < ApplicationController invisible_captcha only: [:create, :update], honeypot: :subtitle - has_orders %w{hot_score confidence_score created_at relevance}, only: :index + has_orders %w{hot_score confidence_score created_at relevance archival_date}, only: :index has_orders %w{most_voted newest oldest}, only: :show load_and_authorize_resource diff --git a/app/models/proposal.rb b/app/models/proposal.rb index 9a92a8d18..d558fdfa7 100644 --- a/app/models/proposal.rb +++ b/app/models/proposal.rb @@ -44,6 +44,8 @@ class Proposal < ActiveRecord::Base scope :sort_by_random, -> { reorder("RANDOM()") } scope :sort_by_relevance, -> { all } scope :sort_by_flags, -> { order(flags_count: :desc, updated_at: :desc) } + scope :sort_by_archival_date, -> { archived.order(created_at: :desc) } + scope :archived, -> { where("proposals.created_at <= ?", 12.months.ago)} scope :last_week, -> { where("proposals.created_at >= ?", 7.days.ago)} scope :retired, -> { where.not(retired_at: nil) } scope :not_retired, -> { where(retired_at: nil) } @@ -155,6 +157,10 @@ class Proposal < ActiveRecord::Base Setting['votes_for_proposal_success'].to_i end + def archived? + self.created_at <= 12.months.ago + end + def notifications proposal_notifications end