diff --git a/app/models/card/entropy.rb b/app/models/card/entropy.rb index d5dd17268..2bec8d0ec 100644 --- a/app/models/card/entropy.rb +++ b/app/models/card/entropy.rb @@ -5,10 +5,9 @@ module Card::Entropy ENTROPY_REMINDER_BEFORE = 7.days included do - scope :in_auto_closing_collection, -> { joins(:collection).merge(Collection.auto_closing) } - - scope :stagnated, -> { doing.where(last_active_at: ..AUTO_RECONSIDER_PERIOD.ago) } - scope :due_to_be_closed, -> { considering.in_auto_closing_collection.where("last_active_at <= DATETIME('now', '-' || entropy_configurations.auto_close_period || ' seconds')") } + scope :with_entropy_configuration, -> { joins(collection: :entropy_configuration) } + scope :stagnated, -> { doing.with_entropy_configuration.where(last_active_at: ..AUTO_RECONSIDER_PERIOD.ago) } + scope :due_to_be_closed, -> { considering.with_entropy_configuration.where("last_active_at <= DATETIME('now', '-' || entropy_configurations.auto_close_period || ' seconds')") } delegate :auto_close_period, :auto_reconsider_period, to: :collection end @@ -34,7 +33,7 @@ module Card::Entropy end def auto_closing? - considering? && collection.auto_closing? && last_active_at + considering? && last_active_at end def auto_close_at diff --git a/app/models/collection/auto_closing.rb b/app/models/collection/auto_closing.rb index c8e52cb12..5f000c48b 100644 --- a/app/models/collection/auto_closing.rb +++ b/app/models/collection/auto_closing.rb @@ -2,14 +2,9 @@ module Collection::AutoClosing extend ActiveSupport::Concern included do - scope :auto_closing, -> { joins(:entropy_configuration).where.not("entropy_configurations.auto_close_period": nil) } before_create :set_default_auto_close_period end - def auto_closing? - entropy_configuration.present? - end - private DEFAULT_AUTO_CLOSE_PERIOD = 30.days