Only active cards can be in doing/considered

This commit is contained in:
Jorge Manrubia
2025-04-03 17:20:43 +02:00
parent 31e30e3053
commit 8c1efa9e89
2 changed files with 16 additions and 6 deletions
+12 -6
View File
@@ -4,25 +4,31 @@ module Bubble::Engageable
included do
has_one :engagement, dependent: :destroy, class_name: "Bubble::Engagement"
scope :doing, -> { joins(:engagement) }
scope :considering, -> { where.missing(:engagement) }
scope :doing, -> { active.joins(:engagement) }
scope :considering, -> { active.where.missing(:engagement) }
end
def doing?
engagement.present?
active? && engagement.present?
end
def considering?
!doing?
active? && !doing?
end
def engage
unless doing?
create_engagement!
transaction do
unpop
create_engagement!
end
end
end
def reconsider
engagement&.destroy
transaction do
unpop
engagement&.destroy
end
end
end
+4
View File
@@ -28,6 +28,10 @@ module Bubble::Poppable
pop.present?
end
def active?
!popped?
end
def popped_by
pop&.user
end