backfill departement services
This commit is contained in:
parent
42d3052c4f
commit
4130529854
2 changed files with 59 additions and 0 deletions
21
app/tasks/maintenance/backfill_departement_services_task.rb
Normal file
21
app/tasks/maintenance/backfill_departement_services_task.rb
Normal file
|
@ -0,0 +1,21 @@
|
|||
# frozen_string_literal: true
|
||||
|
||||
module Maintenance
|
||||
class BackfillDepartementServicesTask < MaintenanceTasks::Task
|
||||
def collection
|
||||
Service.where.not(etablissement_infos: nil)
|
||||
end
|
||||
|
||||
def process(service)
|
||||
code_insee_localite = service.etablissement_infos['code_insee_localite']
|
||||
if code_insee_localite.present?
|
||||
departement = CodeInsee.new(code_insee_localite).to_departement
|
||||
service.update!(departement: departement)
|
||||
end
|
||||
end
|
||||
|
||||
def count
|
||||
collection.count
|
||||
end
|
||||
end
|
||||
end
|
Loading…
Add table
Add a link
Reference in a new issue