Merge pull request #5359 from betagouv/remove-old-after-party-tasks
Suppression d'anciennes tâches de migration de données
This commit is contained in:
commit
a94b42cbad
21 changed files with 0 additions and 452 deletions
|
@ -1,14 +0,0 @@
|
|||
namespace :after_party do
|
||||
desc 'Deployment task: fix_macedonia'
|
||||
task fix_macedonia: :environment do
|
||||
rake_puts "Running deploy task 'fix_macedonia'"
|
||||
|
||||
# Put your task implementation HERE.
|
||||
|
||||
Champ.where(type: "Champs::PaysChamp", value: "EX-REPUBLIQUE YOUGOSLAVE DE MACEDOINE").update_all(value: "MACEDOINE DU NORD (REPUBLIQUE DE)")
|
||||
|
||||
# Update task as completed. If you remove the line below, the task will
|
||||
# run with every deploy (or every time you call after_party:run).
|
||||
AfterParty::TaskRecord.create version: '20190212164238'
|
||||
end # task :fix_macedonia
|
||||
end # namespace :after_party
|
|
@ -1,17 +0,0 @@
|
|||
namespace :after_party do
|
||||
desc 'Deployment task: create_default_path_for_brouillons'
|
||||
task create_default_path_for_brouillons: :environment do
|
||||
rake_puts "Running deploy task 'create_default_path_for_brouillons'"
|
||||
|
||||
# Put your task implementation HERE.
|
||||
|
||||
Procedure.brouillons.where(path: nil).each do |p|
|
||||
p.path = SecureRandom.uuid
|
||||
p.save
|
||||
end
|
||||
|
||||
# Update task as completed. If you remove the line below, the task will
|
||||
# run with every deploy (or every time you call after_party:run).
|
||||
AfterParty::TaskRecord.create version: '20190306172842'
|
||||
end # task :create_default_path_for_brouillons
|
||||
end # namespace :after_party
|
|
@ -1,26 +0,0 @@
|
|||
namespace :after_party do
|
||||
desc 'Deployment task: migrate_mail_body_to_actiontext'
|
||||
task migrate_mail_body_to_actiontext: :environment do
|
||||
rake_puts "Running deploy task 'migrate_mail_body_to_actiontext'"
|
||||
|
||||
# Put your task implementation HERE.
|
||||
|
||||
[Mails::InitiatedMail, Mails::ReceivedMail, Mails::ClosedMail, Mails::WithoutContinuationMail, Mails::RefusedMail].each do |mt_class|
|
||||
progress = ProgressReport.new(mt_class.all.count)
|
||||
|
||||
mt_class.all.each do |mt|
|
||||
if mt.body.present?
|
||||
mt.rich_body = mt.body
|
||||
mt.save
|
||||
end
|
||||
progress.inc
|
||||
end
|
||||
|
||||
progress.finish
|
||||
end
|
||||
|
||||
# Update task as completed. If you remove the line below, the task will
|
||||
# run with every deploy (or every time you call after_party:run).
|
||||
AfterParty::TaskRecord.create version: '20190410131747'
|
||||
end # task :migrate_mail_body_to_actiontext
|
||||
end # namespace :after_party
|
|
@ -1,18 +0,0 @@
|
|||
namespace :after_party do
|
||||
desc 'Deployment task: add_missing_dossier_id_to_repetitions'
|
||||
task add_missing_dossier_id_to_repetitions: :environment do
|
||||
rake_puts "Running deploy task 'add_missing_dossier_id_to_repetitions'"
|
||||
|
||||
champs = Champ.where(dossier_id: nil)
|
||||
progress = ProgressReport.new(champs.count)
|
||||
champs.find_each do |champ|
|
||||
champ.update_column(:dossier_id, champ.parent.dossier_id)
|
||||
progress.inc
|
||||
end
|
||||
progress.finish
|
||||
|
||||
# Update task as completed. If you remove the line below, the task will
|
||||
# run with every deploy (or every time you call after_party:run).
|
||||
AfterParty::TaskRecord.create version: '20190418144354'
|
||||
end
|
||||
end
|
|
@ -1,22 +0,0 @@
|
|||
namespace :after_party do
|
||||
desc 'Deployment task: set_declarative_procedures'
|
||||
task set_declarative_procedures: :environment do
|
||||
rake_puts "Running deploy task 'set_declarative_procedures'"
|
||||
|
||||
Delayed::Job.where.not(cron: nil).find_each do |job|
|
||||
job_data = YAML.load_dj(job.handler).job_data
|
||||
|
||||
if job_data['job_class'] == 'AutoReceiveDossiersForProcedureJob'
|
||||
procedure_id, state = job_data['arguments']
|
||||
procedure = Procedure.find(procedure_id)
|
||||
procedure.declarative_with_state = state
|
||||
procedure.save!
|
||||
job.delete
|
||||
end
|
||||
end
|
||||
|
||||
# Update task as completed. If you remove the line below, the task will
|
||||
# run with every deploy (or every time you call after_party:run).
|
||||
AfterParty::TaskRecord.create version: '20190523122639'
|
||||
end
|
||||
end
|
|
@ -1,10 +0,0 @@
|
|||
namespace :after_party do
|
||||
desc 'Deployment task: populate_user_instructeur_ids'
|
||||
task populate_user_instructeur_ids: :environment do
|
||||
Instructeur.find_each do |instructeur|
|
||||
User.where(email: instructeur.email).update(instructeur_id: instructeur.id)
|
||||
end
|
||||
|
||||
AfterParty::TaskRecord.create version: '20190808145006'
|
||||
end
|
||||
end
|
|
@ -1,10 +0,0 @@
|
|||
namespace :after_party do
|
||||
desc 'Deployment task: populate_user_administrateur_ids'
|
||||
task populate_user_administrateur_ids: :environment do
|
||||
Administrateur.find_each do |administrateur|
|
||||
User.where(email: administrateur.email).update(administrateur_id: administrateur.id)
|
||||
end
|
||||
|
||||
AfterParty::TaskRecord.create version: '20190809074534'
|
||||
end
|
||||
end
|
|
@ -1,30 +0,0 @@
|
|||
namespace :after_party do
|
||||
desc 'Deployment task: clean_procedure_presentation_from_followers_gestionnaires'
|
||||
task clean_procedure_presentation_from_followers_gestionnaires: :environment do
|
||||
ProcedurePresentation.find_each do |pp|
|
||||
if pp.sort["table"] == "followers_gestionnaires"
|
||||
pp.sort["table"] = "followers_instructeurs"
|
||||
end
|
||||
|
||||
pp.displayed_fields.each do |df|
|
||||
if df["table"] == "followers_gestionnaires"
|
||||
df["table"] = "followers_instructeurs"
|
||||
end
|
||||
end
|
||||
|
||||
pp.filters.each do |(_name, values)|
|
||||
values.each do |value|
|
||||
if value["table"] == "followers_gestionnaires"
|
||||
value["table"] = "followers_instructeurs"
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
begin
|
||||
pp.save!
|
||||
rescue StandardError
|
||||
end
|
||||
end
|
||||
AfterParty::TaskRecord.create version: '20190819100424'
|
||||
end
|
||||
end
|
|
@ -1,16 +0,0 @@
|
|||
namespace :after_party do
|
||||
desc 'Deployment task: create_default_groupe_instructeur'
|
||||
task create_default_groupe_instructeur: :environment do
|
||||
Procedure
|
||||
.with_discarded
|
||||
.left_outer_joins(:groupe_instructeurs)
|
||||
.where('groupe_instructeurs.id is null')
|
||||
.find_each do |procedure|
|
||||
procedure.groupe_instructeurs.create(label: GroupeInstructeur::DEFAULT_LABEL)
|
||||
end
|
||||
|
||||
# Update task as completed. If you remove the line below, the task will
|
||||
# run with every deploy (or every time you call after_party:run).
|
||||
AfterParty::TaskRecord.create version: '20190819142551'
|
||||
end
|
||||
end
|
|
@ -1,15 +0,0 @@
|
|||
namespace :after_party do
|
||||
desc 'Deployment task: link_assign_and_groupe_instructeur'
|
||||
task link_assign_and_groupe_instructeur: :environment do
|
||||
AssignTo.find_each do |at|
|
||||
GroupeInstructeur
|
||||
.find_by(procedure_id: at.procedure_id)
|
||||
&.assign_tos
|
||||
&.push(at)
|
||||
end
|
||||
|
||||
# Update task as completed. If you remove the line below, the task will
|
||||
# run with every deploy (or every time you call after_party:run).
|
||||
AfterParty::TaskRecord.create version: '20190819145528'
|
||||
end
|
||||
end
|
|
@ -1,14 +0,0 @@
|
|||
namespace :after_party do
|
||||
desc 'Deployment task: rename_active_storage_attachments'
|
||||
task rename_active_storage_attachments: :environment do
|
||||
rake_puts "Running deploy task 'rename_active_storage_attachments'"
|
||||
|
||||
ActiveStorage::Attachment.where(name: 'logo_active_storage').update_all(name: 'logo')
|
||||
ActiveStorage::Attachment.where(name: 'signature_active_storage').update_all(name: 'signature')
|
||||
ActiveStorage::Attachment.where(name: 'pdf_active_storage').update_all(name: 'pdf')
|
||||
|
||||
# Update task as completed. If you remove the line below, the task will
|
||||
# run with every deploy (or every time you call after_party:run).
|
||||
AfterParty::TaskRecord.create version: '20190828130014'
|
||||
end
|
||||
end
|
|
@ -1,17 +0,0 @@
|
|||
namespace :after_party do
|
||||
desc 'Deployment task: update_admin_last_sign_in_at'
|
||||
task update_admin_last_sign_in_at: :environment do
|
||||
sql = <<-SQL
|
||||
UPDATE users
|
||||
SET last_sign_in_at = administrateurs.updated_at
|
||||
FROM administrateurs
|
||||
WHERE administrateur_id = administrateurs.id
|
||||
AND users.last_sign_in_at IS NULL
|
||||
AND administrateurs.active = true
|
||||
SQL
|
||||
|
||||
ActiveRecord::Base.connection.execute(sql)
|
||||
|
||||
AfterParty::TaskRecord.create version: '20191007124230'
|
||||
end
|
||||
end
|
|
@ -1,15 +0,0 @@
|
|||
namespace :after_party do
|
||||
desc 'Deployment task: archivee_to_close'
|
||||
task archivee_to_close: :environment do
|
||||
puts "Running deploy task 'archivee_to_close'"
|
||||
|
||||
Procedure.where(aasm_state: :archivee).update_all(aasm_state: :close)
|
||||
Procedure.where(aasm_state: :close, closed_at: nil).find_each do |procedure|
|
||||
procedure.update_column(:closed_at, procedure.archived_at)
|
||||
end
|
||||
|
||||
# Update task as completed. If you remove the line below, the task will
|
||||
# run with every deploy (or every time you call after_party:run).
|
||||
AfterParty::TaskRecord.create version: '20191114084623'
|
||||
end
|
||||
end
|
|
@ -1,8 +0,0 @@
|
|||
namespace :after_party do
|
||||
desc 'Deployment task: enable_export_purge'
|
||||
task enable_export_purge: :environment do
|
||||
PurgeStaleExportsJob.set(cron: "*/5 * * * *").perform_later
|
||||
|
||||
AfterParty::TaskRecord.create version: '20191127135401'
|
||||
end
|
||||
end
|
|
@ -1,7 +0,0 @@
|
|||
namespace :after_party do
|
||||
desc 'Deployment task: enable_seek_and_destroy_job'
|
||||
task enable_seek_and_destroy_job: :environment do
|
||||
SeekAndDestroyExpiredDossiersJob.set(cron: "0 7 * * *").perform_later
|
||||
AfterParty::TaskRecord.create version: '20191203142402'
|
||||
end
|
||||
end
|
0
spec/lib/tasks/deployment/.keep
Normal file
0
spec/lib/tasks/deployment/.keep
Normal file
|
@ -1,24 +0,0 @@
|
|||
describe '20190306172842_create_default_path_for_brouillons.rake' do
|
||||
let(:rake_task) { Rake::Task['after_party:create_default_path_for_brouillons'] }
|
||||
|
||||
let(:administrateur) { create(:administrateur) }
|
||||
let!(:procedure) { create(:procedure, administrateur: administrateur) }
|
||||
let!(:procedure2) { create(:simple_procedure, administrateur: administrateur) }
|
||||
|
||||
before do
|
||||
rake_task.invoke
|
||||
administrateur.reload
|
||||
end
|
||||
|
||||
after { rake_task.reenable }
|
||||
|
||||
it 'create a path for his brouillon procedure' do
|
||||
expect(administrateur.procedures.brouillon.count).to eq(1)
|
||||
expect(administrateur.procedures.brouillon.first.path).not_to eq(nil)
|
||||
end
|
||||
|
||||
it 'does not change the path of his published procedure' do
|
||||
expect(administrateur.procedures.publiee.count).to eq(1)
|
||||
expect(administrateur.procedures.publiee.first.path).to eq(procedure2.path)
|
||||
end
|
||||
end
|
|
@ -1,24 +0,0 @@
|
|||
describe '20190410131747_migrate_mail_body_to_actiontext.rake' do
|
||||
let(:rake_task) { Rake::Task['after_party:migrate_mail_body_to_actiontext'] }
|
||||
|
||||
let!(:closed_mail) { create(:closed_mail, body: body) }
|
||||
|
||||
before do
|
||||
rake_task.invoke
|
||||
closed_mail.reload
|
||||
end
|
||||
|
||||
after { rake_task.reenable }
|
||||
|
||||
context 'with a plain text body' do
|
||||
let(:body) { "Test de body" }
|
||||
|
||||
it { expect(closed_mail.rich_body.to_plain_text).to eq(closed_mail.body) }
|
||||
end
|
||||
|
||||
context 'with a html text body' do
|
||||
let(:body) { "Test de body<br>" }
|
||||
|
||||
it { expect(closed_mail.rich_body.to_s.squish).to eq("<div class=\"trix-content\"> #{closed_mail.body} </div>".squish) }
|
||||
end
|
||||
end
|
|
@ -1,84 +0,0 @@
|
|||
describe '20190819100424_clean_procedure_presentation_from_followers_gestionnaires.rake' do
|
||||
let(:rake_task) { Rake::Task['after_party:clean_procedure_presentation_from_followers_gestionnaires'] }
|
||||
|
||||
let(:procedure) { create(:procedure, :with_type_de_champ, :with_type_de_champ_private) }
|
||||
let(:assign_to) { create(:assign_to, procedure: procedure) }
|
||||
|
||||
let!(:procedure_presentation) do
|
||||
pp = ProcedurePresentation.new(
|
||||
assign_to: assign_to,
|
||||
sort: {
|
||||
"order" => "asc",
|
||||
"table" => "followers_gestionnaires",
|
||||
"column" => "email"
|
||||
},
|
||||
filters: {
|
||||
"tous" => [],
|
||||
"suivis" => [],
|
||||
"traites" => [{
|
||||
"label" => "Email instructeur",
|
||||
"table" => "followers_gestionnaires",
|
||||
"value" => "mail@simon.lehericey.net",
|
||||
"column" => "email"
|
||||
}
|
||||
],
|
||||
"a-suivre" => [],
|
||||
"archives" => []
|
||||
},
|
||||
displayed_fields: [
|
||||
{
|
||||
"column" => "email",
|
||||
"label" => "Demandeur",
|
||||
"table" => "user"
|
||||
},
|
||||
{
|
||||
"column" => "email",
|
||||
"label" => "Email instructeur",
|
||||
"table" => "followers_gestionnaires"
|
||||
}
|
||||
]
|
||||
)
|
||||
pp.save(validate: false)
|
||||
pp
|
||||
end
|
||||
|
||||
before do
|
||||
rake_task.invoke
|
||||
procedure_presentation.reload
|
||||
end
|
||||
|
||||
after { rake_task.reenable }
|
||||
|
||||
it do
|
||||
expect(procedure_presentation.displayed_fields[1]["table"]).to eq("followers_instructeurs")
|
||||
expect(procedure_presentation.sort["table"]).to eq("followers_instructeurs")
|
||||
expect(procedure_presentation.filters["traites"][0]["table"]).to eq("followers_instructeurs")
|
||||
end
|
||||
|
||||
context 'with an invalid procedure_presentation' do
|
||||
let!(:procedure_presentation) do
|
||||
pp = ProcedurePresentation.new(
|
||||
assign_to: assign_to,
|
||||
filters: {
|
||||
"tous" => [],
|
||||
"suivis" => [],
|
||||
"traites" => [{
|
||||
"label" => "Email instructeur",
|
||||
"table" => "invalid table",
|
||||
"value" => "mail@simon.lehericey.net",
|
||||
"column" => "email"
|
||||
}
|
||||
],
|
||||
"a-suivre" => [],
|
||||
"archives" => []
|
||||
},
|
||||
displayed_fields: []
|
||||
)
|
||||
pp.save(validate: false)
|
||||
pp
|
||||
end
|
||||
|
||||
it 'does not stop the script' do
|
||||
end
|
||||
end
|
||||
end
|
|
@ -1,45 +0,0 @@
|
|||
describe '20190819142551_create_default_groupe_instructeur.rake' do
|
||||
let(:rake_task) { Rake::Task['after_party:create_default_groupe_instructeur'] }
|
||||
|
||||
subject { rake_task.invoke }
|
||||
after { rake_task.reenable }
|
||||
|
||||
context 'with a procedure without gi' do
|
||||
let!(:procedure_without_gi) { create(:procedure) }
|
||||
|
||||
before do
|
||||
procedure_without_gi.groupe_instructeurs.destroy_all
|
||||
end
|
||||
|
||||
it do
|
||||
expect(procedure_without_gi.groupe_instructeurs).to be_empty
|
||||
subject
|
||||
expect(procedure_without_gi.reload.groupe_instructeurs.pluck(:label)).to eq(['défaut'])
|
||||
end
|
||||
end
|
||||
|
||||
context 'with a procedure discarded without gi' do
|
||||
let!(:procedure_discarded_without_gi) { create(:procedure, :discarded) }
|
||||
|
||||
before do
|
||||
procedure_discarded_without_gi.groupe_instructeurs.destroy_all
|
||||
end
|
||||
|
||||
it do
|
||||
expect(procedure_discarded_without_gi.groupe_instructeurs).to be_empty
|
||||
subject
|
||||
expect(procedure_discarded_without_gi.reload.groupe_instructeurs.pluck(:label)).to eq(['défaut'])
|
||||
end
|
||||
end
|
||||
|
||||
context 'with a procedure with a gi' do
|
||||
let!(:procedure_with_gi) { create(:procedure) }
|
||||
|
||||
it do
|
||||
gi = procedure_with_gi.groupe_instructeurs.first
|
||||
expect(gi).to be_present
|
||||
subject
|
||||
expect(procedure_with_gi.reload.groupe_instructeurs).to eq([gi])
|
||||
end
|
||||
end
|
||||
end
|
|
@ -1,36 +0,0 @@
|
|||
describe '20190819145528_link_assign_and_groupe_instructeur.rake' do
|
||||
let(:rake_task) { Rake::Task['after_party:link_assign_and_groupe_instructeur'] }
|
||||
|
||||
subject { rake_task.invoke }
|
||||
after { rake_task.reenable }
|
||||
|
||||
context 'with an assign_to without groupe_instructeur' do
|
||||
let!(:procedure) { create(:procedure) }
|
||||
let!(:instructeur) { create(:instructeur) }
|
||||
let!(:assign_to) do
|
||||
at = AssignTo.create!(instructeur: instructeur)
|
||||
at.update_column(:procedure_id, procedure.id)
|
||||
at
|
||||
end
|
||||
|
||||
it 'assigns its defaut groupe instructeur' do
|
||||
expect(assign_to.groupe_instructeur).to be_nil
|
||||
subject
|
||||
expect(assign_to.reload.groupe_instructeur).to eq(procedure.defaut_groupe_instructeur)
|
||||
end
|
||||
end
|
||||
|
||||
context 'with an assign_to with groupe_instructeur' do
|
||||
let!(:procedure) { create(:procedure) }
|
||||
let!(:instructeur) { create(:instructeur, groupe_instructeurs: [procedure.defaut_groupe_instructeur]) }
|
||||
let!(:assign_to) { instructeur.assign_to.first }
|
||||
|
||||
it 'assigns its defaut groupe instructeur' do
|
||||
expect(assign_to.groupe_instructeur).to eq(procedure.defaut_groupe_instructeur)
|
||||
expect(procedure.reload.defaut_groupe_instructeur.assign_tos.count).to eq(1)
|
||||
subject
|
||||
expect(instructeur.assign_to).to eq([assign_to])
|
||||
expect(procedure.reload.defaut_groupe_instructeur.assign_tos.count).to eq(1)
|
||||
end
|
||||
end
|
||||
end
|
Loading…
Reference in a new issue