tasks: populate Procedure.administrateurs even for hidden procedures
The previous procedure migration (created in
f7af01e0dc
) worked fine, but didn't run
on hidden procedures (due to the default scope).
This commit is contained in:
parent
2425647fef
commit
8bd1064532
2 changed files with 19 additions and 2 deletions
|
@ -1,8 +1,6 @@
|
||||||
require Rails.root.join('lib', 'percentile')
|
require Rails.root.join('lib', 'percentile')
|
||||||
|
|
||||||
class Procedure < ApplicationRecord
|
class Procedure < ApplicationRecord
|
||||||
self.ignored_columns = [:administrateur_id]
|
|
||||||
|
|
||||||
MAX_DUREE_CONSERVATION = 36
|
MAX_DUREE_CONSERVATION = 36
|
||||||
|
|
||||||
has_many :types_de_piece_justificative, -> { ordered }, dependent: :destroy
|
has_many :types_de_piece_justificative, -> { ordered }, dependent: :destroy
|
||||||
|
|
|
@ -0,0 +1,19 @@
|
||||||
|
namespace :after_party do
|
||||||
|
desc 'Deployment task: add_procedure_administrateur_to_administrateurs_for_hidden_procedures'
|
||||||
|
task add_procedure_administrateur_to_administrateurs_for_hidden_procedures: :environment do
|
||||||
|
rake_puts "Running deploy task: 'add_procedure_administrateur_to_administrateurs_for_hidden_procedures'"
|
||||||
|
hidden_procedures = Procedure.unscoped.hidden.includes(:administrateurs)
|
||||||
|
progress = ProgressReport.new(hidden_procedures.count)
|
||||||
|
|
||||||
|
hidden_procedures.find_each do |procedure|
|
||||||
|
deprecated_administrateur = Administrateur.find_by(id: procedure.administrateur_id)
|
||||||
|
if deprecated_administrateur && !procedure.administrateurs.include?(deprecated_administrateur)
|
||||||
|
procedure.administrateurs << deprecated_administrateur
|
||||||
|
end
|
||||||
|
progress.inc
|
||||||
|
end
|
||||||
|
|
||||||
|
progress.finish
|
||||||
|
AfterParty::TaskRecord.create version: '20190429103024'
|
||||||
|
end
|
||||||
|
end
|
Loading…
Reference in a new issue