<commit_before>class ConvertLanguageCodesToTwoLetters < ActiveRecord::Migration
  def self.up
    Language.find(:all).each do |language|
      language.code.gsub!(/_\w\w/, '')
      language.save!
    end

    User.find(:all, :conditions => "language RLIKE '[a-z][a-z]_[A-Z][A-Z]'").each do |user|
      user.language.gsub!(/_\w\w/, '')
      user.save!
    end

    Group.find(:all, :conditions => "language RLIKE '[a-z][a-z]_[A-Z][A-Z]'").each do |group|
      group.language.gsub!(/_\w\w/, '')
      group.save!<commit_msg>ran into a lot of trouble with data on we.r.n upgrade, so added some rescue errors to migration.<commit_after>class ConvertLanguageCodesToTwoLetters < ActiveRecord::Migration
  def self.up
    Language.find(:all).each do |language|
      language.code.gsub!(/_\w\w/, '')
      language.save!
    end

    User.find(:all, :conditions => "language RLIKE '[a-z][a-z]_[A-Z][A-Z]'").each do |user|
      user.language.gsub!(/_\w\w/, '')
      begin
        user.save!
      rescue StandardError => err
        if err =~ /Email is an invalid email/
          user.update_attribute('email', '')
          user.save!
        else
          puts "Could not save #{user.login}: "+err
        end
      end
    end

    Group.find(:all, :conditions => "language RLIKE '[a-z][a-z]_[A-Z][A-Z]'").each do |group|
      group.language.gsub!(/_\w\w/, '')
      begin
        group.save!
      rescue StandardError => err
        puts "Could not save #{group.name}: "+err
      end
{'fraction_non_alphanumeric': 0.17315436241610738, 'fraction_numerical': 0.0, 'mean_word_length': 2.4836448598130842, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 9, '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': '6440088', 'n_tokens_mistral': 505, 'n_tokens_neox': 504, 'n_words': 109}