<commit_before>class MigrateRunDataToRunGroups < ActiveRecord::Migration
  def change
    add_reference :runs, :run_group
    run_groups = {}

    Run.all.to_a.each do |run|
      unless run_groups.key? run.general_params
        attributes = { general_params: run.general_params, host_name: run.host_name, finished: true }
        run_groups[run.general_params] = RunGroup.create! attributes
      end
      
      run.run_group = run_groups[run.general_params]
      run.save!<commit_msg>avoid problems<commit_after>class MigrateRunDataToRunGroups < ActiveRecord::Migration
  def change
    add_reference :runs, :run_group
    run_groups = {}

    Run.all.to_a.each do |run|
      general_params = run.general_params.sort_by { |k, _| k.to_s }.to_h

      unless run_groups.key? general_params
        attributes = { general_params: general_params, host_name: run.host_name, finished: true }
        run_groups[general_params] = RunGroup.create! attributes
      end

      run.general_params = general_params
      run.run_group = run_groups[general_params]
      run.save!
{'fraction_non_alphanumeric': 0.08744186046511628, 'fraction_numerical': 0.0, 'mean_word_length': 3.4647302904564317, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '6958572', 'n_tokens_mistral': 343, 'n_tokens_neox': 337, 'n_words': 65}