Merge pull request #10708 from mfo/US/format-rna

ETQ tech je souhaite que les champs RNA ne puissent pas contenir d'espace sans quoi nos appels d'API remontent un URI::InvalidURIError
This commit is contained in:
mfo 2024-08-22 08:36:38 +00:00 committed by GitHub
commit 8a42c6a7ad
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
5 changed files with 54 additions and 2 deletions

View file

@ -0,0 +1,19 @@
# frozen_string_literal: true
module Maintenance
class NormalizeRNAValuesTask < MaintenanceTasks::Task
def collection
Champs::RNAChamp.where.not(value: nil)
end
def process(element)
if /\s/.match?(element.value)
element.update_column(:value, element.value.gsub(/\s+/, ''))
end
end
def count
# to costly
end
end
end

View file

@ -16,7 +16,9 @@ module Maintenance
return if data.blank?
champ.update(value_json: APIGeoService.parse_rna_address(data['adresse']))
rescue URI::InvalidURIError
# some data raise this error
# some Champs::RNAChamp contain spaces which raise this error
rescue ActiveRecord::RecordNotFound
# some Champs::RNAChamp procedure had been soft deleted
end
def count