Add selection_utilisateur geo_area to all champs carte with value
This commit is contained in:
parent
c75e39884e
commit
586141a596
1 changed files with 28 additions and 0 deletions
|
@ -0,0 +1,28 @@
|
|||
namespace :after_party do
|
||||
desc 'Deployment task: migrate_geo_area_data'
|
||||
task migrate_geo_area_data: :environment do
|
||||
puts "Running deploy task 'migrate_geo_area_data'"
|
||||
|
||||
progress = ProgressReport.new(Champs::CarteChamp.count)
|
||||
|
||||
Champs::CarteChamp.includes(:geo_areas).find_each do |champ|
|
||||
geo_area = champ.geo_areas.find(&:selection_utilisateur?)
|
||||
geo_json = champ.geo_json_from_value
|
||||
|
||||
if geo_area.blank? && geo_json.present?
|
||||
GeoArea.create(
|
||||
champ: champ,
|
||||
geometry: geo_json,
|
||||
source: GeoArea.sources.fetch(:selection_utilisateur)
|
||||
)
|
||||
progress.inc
|
||||
end
|
||||
end
|
||||
|
||||
progress.finish
|
||||
|
||||
# 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: '20190731152733'
|
||||
end
|
||||
end
|
Loading…
Reference in a new issue