Skip to content

Commit

Permalink
Merged in r2-3066-optimize-calculate_solr_fields (pull request #6962)
Browse files Browse the repository at this point in the history
R2-3066 - Optimize calculate_solr_fields script
  • Loading branch information
aespinoza-quoin authored and pnabutovsky committed Oct 24, 2024
2 parents eddf27a + befec91 commit bca78f3
Showing 1 changed file with 6 additions and 2 deletions.
8 changes: 6 additions & 2 deletions db/data_migration/v2.11/calculate_solr_fields.rb
Original file line number Diff line number Diff line change
Expand Up @@ -41,11 +41,15 @@ def process_records(model_class, record_hashes, batch)
end

def records_to_process(model_class, ids_file_path)
return model_class unless ids_file_path.present?
model_class_and_relations = model_class.eager_loaded_class
model_class_and_relations = model_class_and_relations.includes(:transitions) if model_class.name == 'Child'
model_class_and_relations = model_class_and_relations.includes(:incidents) if model_class.name == 'Child'

return model_class_and_relations unless ids_file_path.present?

print_log("Loading record ids from #{ids_file_path}...")
ids_to_update = File.read(ids_file_path).split
model_class.where(id: ids_to_update)
model_class_and_relations.where(id: ids_to_update)
end

# rubocop:disable Metrics/BlockLength
Expand Down

0 comments on commit bca78f3

Please sign in to comment.