Fix: script should consider old considering cards as belonging to the stream now

This commit is contained in:
Jorge Manrubia
2025-09-27 07:41:55 +02:00
parent 6efd4c8b0e
commit 6a231b48f2
2 changed files with 22 additions and 1 deletions
@@ -2,9 +2,27 @@
require_relative "../../config/environment"
class Card
has_one :engagement, dependent: :destroy, class_name: "Card::Engagement"
def doing?
open? && published? && engagement&.status == "doing"
end
def on_deck?
open? && published? && engagement&.status == "on_deck"
end
def considering?
open? && published? && engagement.blank?
end
end
ApplicationRecord.with_each_tenant do |tenant|
puts "Processing tenant: #{tenant}"
Column.destroy_all
Collection.find_each do |collection|
next unless collection.workflow.present?
@@ -23,7 +41,7 @@ ApplicationRecord.with_each_tenant do |tenant|
# Associate cards with their corresponding columns based on stages
collection.cards.includes(:stage).find_each do |card|
next unless card.stage.present?
next if !card.doing? || card.stage.present?
unless card.stage.workflow.collections.include?(collection)
puts "Corrupt data: the card with id #{card.id} has the stage #{card.stage.name} with id #{card.stage.id} that belongs to a workflow not asociated ot its collection"