refactor(renomme): deplace le phone_fixer.rb dans un repertoire dedié aux fix de data en prod

This commit is contained in:
Martin 2023-10-16 17:25:06 +02:00
parent 9527d19ae7
commit 95bdcc986e
3 changed files with 5 additions and 5 deletions

View file

@ -1,4 +1,4 @@
class PhoneFixer
class DataFixer::ChampsPhoneInvalid
def self.fix(phones_string)
phone_candidates = phones_string
.split(/-/)

View file

@ -2,7 +2,7 @@ require Rails.root.join("lib", "tasks", "task_helper")
namespace :data_fixer do
desc <<~EOD
Given a procedure_id in argument, run the PhoneFixer.
Given a procedure_id in argument, run the DataFixer::ChampsPhoneInvalid.
ex: rails data_fixer:fix_phones\[1\]
EOD
task :fix_phones, [:procedure_id] => :environment do |_t, args|
@ -14,11 +14,11 @@ namespace :data_fixer do
invalid_phone_champs = phone_champs.reject(&:valid?)
fixable_phone_champs = invalid_phone_champs.filter { |phone| PhoneFixer.fixable?(phone.value) }
fixable_phone_champs = invalid_phone_champs.filter { |phone| DataFixer::ChampsPhoneInvalid.fixable?(phone.value) }
fixable_phone_champs.each do |phone|
fixable_phone_value = phone.value
fixed_phone_value = PhoneFixer.fix(fixable_phone_value)
fixed_phone_value = DataFixer::ChampsPhoneInvalid.fix(fixable_phone_value)
if phone.update(value: fixed_phone_value)
rake_puts "Invalid phone #{fixable_phone_value} is fixed as #{fixed_phone_value}"
else

View file

@ -1,4 +1,4 @@
describe PhoneFixer do
describe DataFixer::ChampsPhoneInvalid do
describe '#fix' do
subject { described_class.fix(phone_str) }