Rename en_construction_conservation_extension to conservation_extension
This commit is contained in:
parent
298718936f
commit
1e0d6ea28f
5 changed files with 36 additions and 2 deletions
|
@ -161,7 +161,8 @@ module Users
|
|||
end
|
||||
|
||||
def extend_conservation
|
||||
dossier.update(en_construction_conservation_extension: dossier.en_construction_conservation_extension + 1.month)
|
||||
dossier.update(en_construction_conservation_extension: dossier.en_construction_conservation_extension + 1.month,
|
||||
conservation_extension: dossier.en_construction_conservation_extension + 1.month)
|
||||
flash[:notice] = 'Votre dossier sera conservé un mois supplémentaire'
|
||||
redirect_to dossier_path(@dossier)
|
||||
end
|
||||
|
|
|
@ -7,6 +7,7 @@
|
|||
# archived :boolean default(FALSE)
|
||||
# autorisation_donnees :boolean
|
||||
# brouillon_close_to_expiration_notice_sent_at :datetime
|
||||
# conservation_extension :interval default(0 seconds)
|
||||
# deleted_user_email_never_send :string
|
||||
# en_construction_at :datetime
|
||||
# en_construction_close_to_expiration_notice_sent_at :datetime
|
||||
|
@ -636,6 +637,7 @@ class Dossier < ApplicationRecord
|
|||
end
|
||||
|
||||
def after_passer_en_construction
|
||||
update!(conservation_extension: 0.days)
|
||||
update!(en_construction_at: Time.zone.now) if self.en_construction_at.nil?
|
||||
end
|
||||
|
||||
|
@ -652,6 +654,7 @@ class Dossier < ApplicationRecord
|
|||
end
|
||||
|
||||
def after_repasser_en_construction(instructeur)
|
||||
update!(conservation_extension: 0.days)
|
||||
log_dossier_operation(instructeur, :repasser_en_construction)
|
||||
end
|
||||
|
||||
|
|
|
@ -0,0 +1,5 @@
|
|||
class AddConservationExtensionToDossiers < ActiveRecord::Migration[6.1]
|
||||
def change
|
||||
add_column :dossiers, :conservation_extension, :interval
|
||||
end
|
||||
end
|
|
@ -10,7 +10,7 @@
|
|||
#
|
||||
# It's strongly recommended that you check this file into your version control system.
|
||||
|
||||
ActiveRecord::Schema.define(version: 2021_05_04_115445) do
|
||||
ActiveRecord::Schema.define(version: 2021_05_05_115445) do
|
||||
|
||||
# These are extensions that must be enabled in order to support this database
|
||||
enable_extension "plpgsql"
|
||||
|
@ -274,6 +274,7 @@ ActiveRecord::Schema.define(version: 2021_05_04_115445) do
|
|||
t.datetime "last_avis_updated_at"
|
||||
t.datetime "last_commentaire_updated_at"
|
||||
t.string "api_entreprise_job_exceptions", array: true
|
||||
t.interval "conservation_extension"
|
||||
t.string "deleted_user_email_never_send"
|
||||
t.index "to_tsvector('french'::regconfig, (search_terms || private_search_terms))", name: "index_dossiers_on_search_terms_private_search_terms", using: :gin
|
||||
t.index "to_tsvector('french'::regconfig, search_terms)", name: "index_dossiers_on_search_terms", using: :gin
|
||||
|
|
|
@ -0,0 +1,24 @@
|
|||
namespace :after_party do
|
||||
desc 'Deployment task: rename_conservation_extension'
|
||||
task rename_conservation_extension: :environment do
|
||||
puts "Running deploy task 'rename_conservation_extension'"
|
||||
|
||||
BATCH_SIZE = 20000
|
||||
|
||||
dossiers = Dossier.state_en_construction.where.not(en_construction_conservation_extension: 0.days)
|
||||
dossiers.find_each do |dossier|
|
||||
dossier.update_column(:conservation_extension, dossier.en_construction_conservation_extension)
|
||||
end
|
||||
|
||||
dossiers = Dossier.where(conservation_extension: nil)
|
||||
n = (dossiers.count / BATCH_SIZE).ceil + 1
|
||||
n.times do
|
||||
dossiers.limit(BATCH_SIZE).update_all(conservation_extension: 0.days)
|
||||
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: AfterParty::TaskRecorder.new(__FILE__).timestamp
|
||||
end
|
||||
end
|
Loading…
Reference in a new issue