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
+3
View File
@@ -2,12 +2,15 @@
<%= button_to "Not now", card_not_now_path(card),
class: [ "btn justify-start workflow-stage txt-uppercase", { "workflow-stage--current": card.postponed? } ],
form_class: "flex align-center gap-half" %>
<%= button_to "The Stream", card_triage_path(card), method: :delete,
class: [ "btn justify-start workflow-stage txt-uppercase", { "workflow-stage--current": card.awaiting_triage? } ],
form_class: "flex align-center gap-half" %>
<% card.collection.columns.each do |column| %>
<%= button_to_set_column card, column %>
<% end %>
<%= button_to "Closed", card_closure_path(card, reason: "Completed"),
class: [ "btn justify-start workflow-stage txt-uppercase", { "workflow-stage--current": card.closed? } ],
form_class: "flex align-center gap-half" %>
@@ -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"