Remove old (< 2019) migration tasks
This commit is contained in:
parent
a66032333b
commit
a3cf7fce3a
64 changed files with 0 additions and 1855 deletions
|
@ -1,8 +0,0 @@
|
|||
namespace :after_party do
|
||||
desc 'Deployment task: remove_path_from_archived_procedures'
|
||||
task remove_path_from_archived_procedures: :environment do
|
||||
Procedure.archivees.where.not(path: nil).update_all(path: nil)
|
||||
|
||||
AfterParty::TaskRecord.create version: '20181031104615'
|
||||
end
|
||||
end
|
|
@ -1,128 +0,0 @@
|
|||
require Rails.root.join("lib", "tasks", "task_helper")
|
||||
|
||||
namespace :after_party do
|
||||
desc 'Deployment task: approve / reject dossiers for procedure 8670'
|
||||
task mass_process_procedure_8670_dossiers: :environment do
|
||||
class MassProcessProcedure8670
|
||||
DOSSIER_IDS_TO_ACCEPT = [
|
||||
194722, 172178, 170186, 177122, 171783, 173930, 176042, 183202, 192081, 170387,
|
||||
171136, 171765, 173743, 173784, 173802, 173904, 173915, 171744, 173945, 170839,
|
||||
173954, 173967, 173990, 174003, 172217, 170449, 176603, 175921, 172634, 179048,
|
||||
180970, 181508, 182035, 181526, 178543, 170822, 170782, 186579, 187928, 188183,
|
||||
188399, 176860, 170614, 194011, 194100, 196307, 200282, 171544, 201953, 176316,
|
||||
205882, 205907, 205962, 178940, 181650, 202114, 180333, 174687, 192439, 169826,
|
||||
170121, 169894, 170635, 170626, 171896, 171993, 171935, 172028, 172087, 172094,
|
||||
172138, 172206, 172456, 172468, 172533, 172627, 172758, 172834, 172845, 172879,
|
||||
172884, 173411, 173662, 172256, 173909, 191259, 197681, 200041, 177306, 202624,
|
||||
203230, 204556, 205785, 198252, 170227, 173513, 172296, 174292, 174483, 174492,
|
||||
175076, 176540, 177177, 177322, 183210, 183498, 184353, 195189, 195967, 186147,
|
||||
170799, 178152, 177440, 184132, 169967, 175335, 177364, 179365, 197527, 172820,
|
||||
187060, 200326, 169921, 183622, 174745, 175484, 174512, 180860, 189163, 170054,
|
||||
170106, 206667, 170263, 173759, 169879, 170632, 190310, 170325, 170336, 170650,
|
||||
171520, 171050, 170414, 173804, 173911, 173947, 178986, 172030, 177428, 182875,
|
||||
198458, 199080, 172489, 200406, 204297, 171184, 171265, 171338, 171347, 172620,
|
||||
173162, 171939, 171597, 173878, 173758, 175861, 175923, 176851, 176957, 172479,
|
||||
183279, 177429, 185382, 185586, 188898, 172840, 180340, 195351, 171135, 170583,
|
||||
171680, 174150, 175066, 177164, 172951, 170623, 172863, 178732, 178268, 179848,
|
||||
179896, 179923, 179283, 180083, 185764, 192455, 190329, 197121, 169897, 170005,
|
||||
170023, 170127, 170399, 170371, 170351, 170519, 170654, 170680, 170774, 170781,
|
||||
171892, 169828, 171989, 172070, 171952, 171923, 172184, 174859, 175560, 175865,
|
||||
172922, 171889, 173550, 181501, 179897, 185241, 190364, 193743, 178551, 199361,
|
||||
173739, 169885, 169893, 171777, 179338, 179818, 170339, 178090, 187012, 191063,
|
||||
179911, 195101, 177916, 170242, 173537, 173895, 173700, 174642, 174749, 174880,
|
||||
174818, 175011, 174863, 175422, 175644, 177797, 177829, 174276, 200208, 204312,
|
||||
204356, 179106, 177928, 180376, 181086, 180048, 192202, 194193, 204479, 204979,
|
||||
183388, 185549
|
||||
]
|
||||
|
||||
DOSSIER_IDS_TO_REJECT = [
|
||||
172516, 177423, 177002, 179031, 176856, 179193, 179237, 179333, 179912, 179949,
|
||||
181001, 185704, 185710, 177001, 186898, 175420, 175412, 195668, 174463, 175347,
|
||||
174606, 176668, 176749, 177007, 177037, 174306, 177373, 174496, 174583, 205297,
|
||||
191646, 178553, 184288, 174296, 199563, 202567, 180596, 194441, 196523, 183504,
|
||||
190011, 184563, 175047, 177243, 174108, 174423, 170552, 171931, 170955, 170415,
|
||||
170652, 170145, 170044, 169841, 171280, 177569, 174711, 180357, 180554, 175594,
|
||||
181370, 180370, 180279, 182877, 188432, 183516, 191845, 184965, 198962, 199250,
|
||||
202324, 205887, 172006, 196073, 197861, 198389, 188855, 198639, 203881, 205520,
|
||||
205626, 206468, 196904, 206619, 206730, 175088, 191405, 173038, 195082, 185849,
|
||||
188454, 188501, 188713, 171057, 177541, 177882, 178185, 178951, 178962, 178997,
|
||||
179090, 179234, 173959, 177621, 174022, 181414, 181895, 183081, 175935, 175951,
|
||||
176156, 176200, 176506, 176567, 173898, 173906, 173905, 173932, 173810, 173949,
|
||||
173961, 174033, 172939, 174227, 172362, 173008, 174979, 173396, 173196, 172143,
|
||||
173790, 173745, 173779, 172151, 170332, 171424, 171434, 170459, 171635, 171689,
|
||||
170409, 171429, 171940, 170266, 172632, 172742, 170689, 206612, 169877, 170402,
|
||||
170563, 170605, 170658, 170653, 170699, 170511, 170835, 183559, 187911, 188163,
|
||||
188685, 188702, 170678, 183994, 173899, 194530, 194873, 194433, 173971, 174004,
|
||||
174239, 174430, 175849, 175850, 176265, 176630, 176789, 175946, 172407, 177398,
|
||||
170027, 170002, 170404, 173678, 170655, 170328, 170405, 170686, 171106, 171763,
|
||||
172317, 172763, 172880, 173250, 174938, 170714, 175798, 175899, 176015, 176041,
|
||||
176258, 176341, 176909, 176944, 174031, 180109, 170316, 174100, 174540, 175910,
|
||||
177872, 178117, 179092, 183923, 175005, 185795, 186580, 181383, 189186, 194998,
|
||||
177475, 174446, 180508, 181216, 181290, 181905, 191344, 187745, 192016, 193188,
|
||||
170201, 170288, 170568
|
||||
]
|
||||
|
||||
def run
|
||||
rake_puts "Running deploy task 'mass_process_procedure_8670_dossiers'\n"
|
||||
|
||||
reject_dossiers
|
||||
accept_dossiers
|
||||
|
||||
AfterParty::TaskRecord.create version: '20181106170434'
|
||||
end
|
||||
|
||||
def reject_dossiers
|
||||
rake_puts "Rejecting dossiers\n"
|
||||
|
||||
dossiers_for_traitement.where(id: DOSSIER_IDS_TO_REJECT).find_each do |dossier|
|
||||
if skip_dossier?(dossier)
|
||||
next
|
||||
end
|
||||
|
||||
dossier.update(
|
||||
state: Dossier.states.fetch(:refuse),
|
||||
motivation: "Malheureusement, votre dossier n'a pas été tiré au sort",
|
||||
processed_at: Time.zone.now
|
||||
)
|
||||
NotificationMailer.send_refused_notification(dossier).deliver_later
|
||||
end
|
||||
end
|
||||
|
||||
def accept_dossiers
|
||||
rake_puts "Accepting dossiers\n"
|
||||
|
||||
dossiers_for_traitement.where(id: DOSSIER_IDS_TO_ACCEPT).find_each do |dossier|
|
||||
if skip_dossier?(dossier)
|
||||
next
|
||||
end
|
||||
|
||||
dossier.update(
|
||||
state: Dossier.states.fetch(:accepte),
|
||||
processed_at: Time.zone.now
|
||||
)
|
||||
dossier.attestation = dossier.build_attestation
|
||||
dossier.save
|
||||
NotificationMailer.send_closed_notification(dossier).deliver_later
|
||||
end
|
||||
end
|
||||
|
||||
def dossiers_for_traitement
|
||||
Dossier.includes(:procedure, :user, :etablissement, :champs, :champs_private)
|
||||
end
|
||||
|
||||
def skip_dossier?(dossier)
|
||||
if dossier.procedure_id != 8670
|
||||
rake_puts "Skipping dossier #{dossier.id} (wrong procedure)\n"
|
||||
return true
|
||||
end
|
||||
if !dossier.en_instruction?
|
||||
rake_puts "Skipping dossier #{dossier.id} (not en instruction)\n"
|
||||
return true
|
||||
end
|
||||
return false
|
||||
end
|
||||
end
|
||||
|
||||
MassProcessProcedure8670.new.run
|
||||
end
|
||||
end
|
|
@ -1,54 +0,0 @@
|
|||
require Rails.root.join("lib", "tasks", "task_helper")
|
||||
|
||||
namespace :after_party do
|
||||
# Matches "ne pas répondre", plus some content before and after:
|
||||
# - try to remove dashes before the footer
|
||||
# - try to remove line-breaks and empty HTML tags before the footer text
|
||||
# - matches "Veuillez ne pas répondre" or "Merci de ne pas répondre"
|
||||
# - once the footer text is found, extend the match to the end of the body
|
||||
FOOTER_REGEXP = /(—|---|-)?( |\r|\n|<br>|<p>|<\/p>|<small>|<\/small>|<b>|<\/b>| )*(Veuillez)?(Merci)?( |\r|\n)*(de)? ne pas répondre(.*)$/m
|
||||
# When the footer contains any of these words, it is kept untouched.
|
||||
FOOTER_EXCEPTIONS = [
|
||||
'PDF',
|
||||
'@',
|
||||
'Hadrien',
|
||||
'Esther',
|
||||
'Sicoval',
|
||||
'a323',
|
||||
'SNC',
|
||||
'Polynésie',
|
||||
'drac',
|
||||
'theplatform'
|
||||
]
|
||||
|
||||
desc 'Deployment task: remove_footer_from_email_templates'
|
||||
task remove_footer_from_email_templates: :environment do
|
||||
rake_puts "Running deploy task 'remove_footer_from_email_templates'"
|
||||
|
||||
models = [
|
||||
Mails::ClosedMail,
|
||||
Mails::InitiatedMail,
|
||||
Mails::ReceivedMail,
|
||||
Mails::RefusedMail,
|
||||
Mails::WithoutContinuationMail
|
||||
]
|
||||
|
||||
models.each do |model_class|
|
||||
model_class.all.find_each do |template|
|
||||
remove_footer(template)
|
||||
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: '20181120133842'
|
||||
end # task :remove_footer_from_email_templates
|
||||
|
||||
def remove_footer(template)
|
||||
matches = template.body.match(FOOTER_REGEXP)
|
||||
if matches && FOOTER_EXCEPTIONS.none? { |exception| matches[0].include?(exception) }
|
||||
rake_puts "#{template.model_name} \##{template.id}: removing footer"
|
||||
template.update(body: matches.pre_match)
|
||||
end
|
||||
end
|
||||
end # namespace :after_party
|
|
@ -1,28 +0,0 @@
|
|||
require 'rake-progressbar'
|
||||
|
||||
namespace :after_party do
|
||||
desc 'Deployment task: fix_notifications_after_carto_migration'
|
||||
task fix_notifications_after_carto_migration: :environment do
|
||||
def fix_notifications(dossier)
|
||||
updated_at = dossier.champs[1..-1].map(&:updated_at).max
|
||||
champ_carte = dossier.champs.first
|
||||
if updated_at && (!champ_carte.updated_at || champ_carte.updated_at > updated_at)
|
||||
champ_carte.update_columns(updated_at: updated_at, created_at: updated_at)
|
||||
end
|
||||
end
|
||||
|
||||
dossiers = Dossier.includes(:champs)
|
||||
.joins(procedure: :module_api_carto)
|
||||
.where(procedure: { module_api_cartos: { migrated: true } })
|
||||
|
||||
bar = RakeProgressbar.new(dossiers.count)
|
||||
|
||||
dossiers.find_each do |dossier|
|
||||
fix_notifications(dossier)
|
||||
bar.inc
|
||||
end
|
||||
bar.finished
|
||||
|
||||
AfterParty::TaskRecord.create version: '20181121153709'
|
||||
end
|
||||
end
|
|
@ -1,15 +0,0 @@
|
|||
namespace :after_party do
|
||||
desc 'Deployment task: add_stable_id_to_types_de_champ'
|
||||
task add_stable_id_to_types_de_champ: :environment do
|
||||
types_de_champ = TypeDeChamp.where(stable_id: nil)
|
||||
bar = RakeProgressbar.new(types_de_champ.count)
|
||||
|
||||
types_de_champ.find_each do |type_de_champ|
|
||||
type_de_champ.update_column(:stable_id, type_de_champ.id)
|
||||
bar.inc
|
||||
end
|
||||
bar.finished
|
||||
|
||||
AfterParty::TaskRecord.create version: '20181123181252'
|
||||
end
|
||||
end
|
|
@ -1,17 +0,0 @@
|
|||
namespace :after_party do
|
||||
desc 'Deployment task: destroy_orphaned_dossier_operation_logs'
|
||||
task destroy_orphaned_dossier_operation_logs: :environment do
|
||||
bar = RakeProgressbar.new(DossierOperationLog.count)
|
||||
|
||||
DossierOperationLog.find_each do |log|
|
||||
if log.dossier.blank?
|
||||
log.destroy
|
||||
end
|
||||
bar.inc
|
||||
end
|
||||
|
||||
bar.finished
|
||||
|
||||
AfterParty::TaskRecord.create version: '20181128155650'
|
||||
end
|
||||
end
|
|
@ -1,20 +0,0 @@
|
|||
namespace :after_party do
|
||||
desc 'Deployment task: remove_champ_pj_feature'
|
||||
task remove_champ_pj_feature: :environment do
|
||||
rake_puts "Running deploy task 'remove_champ_pj_feature'"
|
||||
|
||||
Administrateur.find_by_sql(
|
||||
<<~SQL
|
||||
SELECT administrateurs.*
|
||||
FROM administrateurs, lateral jsonb_each(features)
|
||||
WHERE key = 'champ_pj'
|
||||
GROUP BY id
|
||||
SQL
|
||||
).each do |admin|
|
||||
admin.features.delete('champ_pj')
|
||||
admin.save
|
||||
end
|
||||
|
||||
AfterParty::TaskRecord.create version: '20181210185634'
|
||||
end
|
||||
end
|
|
@ -1,28 +0,0 @@
|
|||
namespace :after_party do
|
||||
desc 'Deployment task: fix_email_templates_subjects'
|
||||
task fix_email_templates_subjects: :environment do
|
||||
rake_puts "Running deploy task 'fix_email_templates_subjects'"
|
||||
|
||||
klasses = [
|
||||
Mails::ClosedMail,
|
||||
Mails::InitiatedMail,
|
||||
Mails::ReceivedMail,
|
||||
Mails::RefusedMail,
|
||||
Mails::WithoutContinuationMail
|
||||
]
|
||||
|
||||
klasses.each do |klass|
|
||||
klass
|
||||
.where("subject LIKE '%--libellé procédure--%'")
|
||||
.each do |instance|
|
||||
|
||||
instance.update(subject: instance.subject.gsub("--libellé procédure--", "--libellé démarche--"))
|
||||
rake_puts "Subject mis-à-jour pour #{klass}##{instance.id}"
|
||||
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: '20181219122438'
|
||||
end # task :fix_email_templates_subjects
|
||||
end # namespace :after_party
|
|
@ -1,17 +0,0 @@
|
|||
namespace :after_party do
|
||||
desc 'Deployment task: migrate_types_de_champ_options_to_json'
|
||||
task migrate_types_de_champ_options_to_json: :environment do
|
||||
rake_puts "Running deploy task 'migrate_types_de_champ_options_to_json'"
|
||||
|
||||
dirty_tdcs = TypeDeChamp.where.not(options: nil)
|
||||
progress = ProgressReport.new(dirty_tdcs.count)
|
||||
dirty_tdcs.find_each do |tdc|
|
||||
tdc.options_will_change!
|
||||
tdc.save
|
||||
progress.inc
|
||||
end
|
||||
progress.finish
|
||||
|
||||
AfterParty::TaskRecord.create version: '20181219175043'
|
||||
end
|
||||
end
|
Loading…
Add table
Add a link
Reference in a new issue