Skip to content

How to add missing workflow steps

Andrew Berger edited this page Feb 17, 2023 · 3 revisions

Given a list of druids where it is known that certain workflow steps should be present in a certain status, you can run a loop such as the following from the Rails console:

workflow_name = 'accessionWF'
step_name = 'shelve-complete'
step_status = 'completed'
CSV.foreach('druids-in-error.csv') do |row| # CSV of druids obtained from e.g. argo solr query for druids with error on a particular workflow step
  druid = row.first
  max_version = WorkflowStep.where(druid: druid, workflow: workflow_name).pluck('version').max
  # add the step only if it's missing
  # repository col likely going away, see https://github.com/sul-dlss/workflow-server-rails/pull/280
  WorkflowStep.find_or_create_by(druid: druid, workflow: workflow_name, version: max_version, process: step_name, status: step_status)
end