All the collections are "auto closing now"

This commit is contained in:
Jorge Manrubia
2025-06-04 11:44:18 +02:00
parent 2ee857a4d2
commit 6501604a5f
2 changed files with 4 additions and 10 deletions
+4 -5
View File
@@ -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
-5
View File
@@ -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