Merge pull request #10554 from mfo/US/fix-export-decimal
ETQ admin/instructeur, je souhaite récupérer la valeur d'un type de champ decimal même si la valeur est précédé et ou suivi d'espace blanc
This commit is contained in:
commit
bc6e2a40ba
3 changed files with 79 additions and 0 deletions
20
app/tasks/maintenance/fix_decimal_number_with_spaces_task.rb
Normal file
20
app/tasks/maintenance/fix_decimal_number_with_spaces_task.rb
Normal file
|
@ -0,0 +1,20 @@
|
|||
# frozen_string_literal: true
|
||||
|
||||
module Maintenance
|
||||
class FixDecimalNumberWithSpacesTask < MaintenanceTasks::Task
|
||||
ANY_SPACES = /[[:space:]]/
|
||||
def collection
|
||||
Champs::DecimalNumberChamp.where.not(value: nil)
|
||||
end
|
||||
|
||||
def process(element)
|
||||
if element.value.present? && ANY_SPACES.match?(element.value)
|
||||
element.update_column(:value, element.value.gsub(ANY_SPACES, ''))
|
||||
end
|
||||
end
|
||||
|
||||
def count
|
||||
# not really interested in counting because it raises PG Statement timeout
|
||||
end
|
||||
end
|
||||
end
|
Loading…
Add table
Add a link
Reference in a new issue