Merge pull request #10321 from demarches-simplifiees/add_maintenance_task_to_move_dol_to_cold_storage
Tech: ajoute une tache de maintenance pour rattraper les dossier operation log qui n'ont leur data sur le cold storage
This commit is contained in:
commit
716099e2d7
1 changed files with 25 additions and 0 deletions
25
app/tasks/maintenance/move_dol_to_cold_storage_task.rb
Normal file
25
app/tasks/maintenance/move_dol_to_cold_storage_task.rb
Normal file
|
@ -0,0 +1,25 @@
|
||||||
|
# frozen_string_literal: true
|
||||||
|
|
||||||
|
module Maintenance
|
||||||
|
class MoveDolToColdStorageTask < MaintenanceTasks::Task
|
||||||
|
attribute :start_text, :string
|
||||||
|
validates :start_text, presence: true
|
||||||
|
|
||||||
|
attribute :end_text, :string
|
||||||
|
validates :end_text, presence: true
|
||||||
|
|
||||||
|
def collection
|
||||||
|
start_date = DateTime.parse(start_text)
|
||||||
|
end_date = DateTime.parse(end_text)
|
||||||
|
# Collection to be iterated over
|
||||||
|
# Must be Active Record Relation or Array
|
||||||
|
DossierOperationLog.where(created_at: start_date..end_date)
|
||||||
|
end
|
||||||
|
|
||||||
|
def process(dol)
|
||||||
|
return if dol.data.nil?
|
||||||
|
|
||||||
|
dol.move_to_cold_storage!
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
Loading…
Add table
Reference in a new issue