data: add naive maintenance task to cold storage dol
This commit is contained in:
parent
cb2dd3dd3a
commit
120eb4253c
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…
Reference in a new issue