Created
September 25, 2020 13:07
-
-
Save camallen/44972b25a3359b649f5338d23fb203d2 to your computer and use it in GitHub Desktop.
Unretire subects for a workflow
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
workflow_ids = [] | |
subject_set_ids = [] | |
workflow_ids.map do |wf_id| | |
subject_set_ids.map do |set_id| | |
set_subject_ids = SetMemberSubject.where(subject_set_id: set_id).pluck(:subject_id) | |
# UNCOMMMENT ONE OF THESE, I DO A SANITY CHECK COUNT FIRST, THEN UNRETIRE | |
# run a count for sanity check | |
# SubjectWorkflowStatus.where.not(retired_at: nil).where(workflow_id: wf_id, subject_id: set_subject_ids).count | |
# RUN THE UNRETIRE | |
SubjectWorkflowStatus.where.not(retired_at: nil).where(workflow_id: wf_id, subject_id: set_subject_ids).update_all(retired_at: nil, retirement_reason: nil) | |
end | |
end | |
# reset the counts, wf finished state etc | |
# and resync the subject selector service | |
workflow_ids.map do |wf_id| | |
RefreshWorkflowStatusWorker.perform_async(wf_id) | |
NotifySubjectSelectorOfChangeWorker.perform_async(wf_id) | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment