<commit_before>class LicenceIdentifierMigrator

  LICENCE_MAPPING_URL = "https://raw.github.com/alphagov/licence-finder/correlation_id_migration/data/licence_gds_ids.yaml"
  
  def self.update_all
    counter = 0
    licence_mappings = mappings_as_hash
    puts licence_mappings
    
    LicenceEdition.all.each do |licence_edition|
      licence_identifier = licence_mappings[licence_edition.licence_identifier.to_i]
      if licence_identifier
        licence_edition = licence_edition.build_clone if licence_edition.state == 'published'
        licence_edition.licence_identifier = licence_identifier
        licence_edition.save! 
        counter += 1
      end
      done(counter, "\r")
    end
    done(counter, "\n")
  end
  
  def self.mappings_as_hash
    YAML.load(Curl::Easy.http_get(LICENCE_MAPPING_URL).body_str)
  end
<commit_msg>Removing debug of yaml contents<commit_after>class LicenceIdentifierMigrator

  LICENCE_MAPPING_URL = "https://raw.github.com/alphagov/licence-finder/correlation_id_migration/data/licence_gds_ids.yaml"
  
  def self.update_all
    counter = 0
    licence_mappings = mappings_as_hash
    
    LicenceEdition.all.each do |licence_edition|
      licence_identifier = licence_mappings[licence_edition.licence_identifier.to_i]
      if licence_identifier
        licence_edition = licence_edition.build_clone if licence_edition.state == 'published'
        licence_edition.licence_identifier = licence_identifier
        licence_edition.save! 
        counter += 1
      end
      done(counter, "\r")
    end
    done(counter, "\n")
  end
  
  def self.mappings_as_hash
    YAML.load(Curl::Easy.http_get(LICENCE_MAPPING_URL).body_str)
  end

{'fraction_non_alphanumeric': 0.07738095238095238, 'fraction_numerical': 0.002380952380952381, 'mean_word_length': 3.656509695290859, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 2, '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': '953916', 'n_tokens_mistral': 593, 'n_tokens_neox': 563, 'n_words': 82}