2024-09-10 18:16:16 +02:00
|
|
|
# frozen_string_literal: true
|
|
|
|
|
|
|
|
module Maintenance
|
|
|
|
# PR: 10774
|
2024-10-07 09:54:17 +02:00
|
|
|
# why: postgres does not support integer greater than FilteredColumn::PG_INTEGER_MAX_VALUE)
|
2024-09-10 18:16:16 +02:00
|
|
|
# it occures when user copypaste the dossier id twice (like missed copy paste,paste)
|
|
|
|
# once this huge integer is saved on procedure presentation, page with this filter can't be loaded
|
|
|
|
# when: run this migration when it appears in your maintenance tasks list, this file fix the data and we added some validations too
|
|
|
|
class CleanInvalidProcedurePresentationTask < MaintenanceTasks::Task
|
|
|
|
def collection
|
|
|
|
ProcedurePresentation.all
|
|
|
|
end
|
|
|
|
|
|
|
|
def process(element)
|
|
|
|
element.filters = element.filters.transform_values do |filters_by_status|
|
|
|
|
filters_by_status.reject do |filter|
|
|
|
|
filter.is_a?(Hash) &&
|
|
|
|
filter['column'] == 'id' &&
|
2024-10-07 09:54:17 +02:00
|
|
|
(filter['value']&.to_i&. >= FilteredColumn::PG_INTEGER_MAX_VALUE)
|
2024-09-10 18:16:16 +02:00
|
|
|
end
|
|
|
|
end
|
|
|
|
element.save
|
|
|
|
end
|
|
|
|
|
|
|
|
def count
|
|
|
|
# Optionally, define the number of rows that will be iterated over
|
|
|
|
# This is used to track the task's progress
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|