# frozen_string_literal: true
# This task nullifies the names of MboProfiles that were autogenerated based on specific patterns
class Maintenance::NullifyAutogeneratedMboProfileNames < MaintenanceTasks::Task
def collection
MboProfile
.joins(:tree_nodes, :country)
.where("(mbo_profiles.name ilike '%' || mbo_id || '%')").in_batches
end
def process(mbo_profiles)
mbo_profiles.find_each do |mbo_profile|
next unless mbo_profile.name_matches_autogenerated_pattern?
mbo_profile.update!(name: nil)
end
end
end