Ran for less than 5 seconds, finished .
# frozen_string_literal: true
# Backfills sync_data_source to ATOM on CustomFields Atom already synced in before the column
# existed. Takes a CSV with a single custom_field_id column and stamps that field directly —
# no content matching, since the id already uniquely identifies the field.
class Maintenance::Atom::BackfillCustomFieldSyncDataSourceTask < MaintenanceTasks::Task
csv_collection
def collection
CSV.parse(csv_content, headers: true, encoding: 'UTF-8').map(&:to_h)
end
def count
collection.size
end
def process(row)
custom_field = CustomField.find_by(id: row['custom_field_id'])
unless custom_field
log_not_found(row)
return
end
return if custom_field.sync_data_source == CustomFields::SyncDataSource::ATOM
# rubocop:disable-next Rails/SkipsModelValidations
custom_field.update_column(:sync_data_source, CustomFields::SyncDataSource::ATOM)
rescue StandardError => e
Rails.logger.error("BackfillCustomFieldSyncDataSourceTask: failed for id=#{row['custom_field_id']}: #{e.message}")
end
private
def log_not_found(row)
Rails.logger.warn(
"BackfillCustomFieldSyncDataSourceTask: no CustomField found for id=#{row['custom_field_id']}"
)
end
end
Processed 1 out of 1 item (100%).
Ran for less than 5 seconds, finished .
-1
Processed 1 out of 1 item (100%).
Ran for less than 5 seconds, finished .
-1
Processed 1 out of 1 item (100%).
Ran for less than 5 seconds, finished .
-1
Processed 1 out of 1 item (100%).
Ran for less than 5 seconds, finished .
-1
Processed 1 out of 1 item (100%).
Ran for less than 5 seconds, finished .
-1
Processed 1 out of 1 item (100%).
Ran for less than 5 seconds, finished .
-1