<commit_before>class UpdateBarFor2010 < ActiveRecord::Migration
  def self.up
    downhill = Discipline[:downhill]
    downhill.bar_categories.clear
    downhill.bar = false
    downhill.save!
    
    short_track = Discipline.create!(:name => "Short Track", :bar => true)
    short_track.bar_categories << Category.find_by_name("Category 3 Men")
    short_track.bar_categories << Category.find_by_name("Category 3 Women")
    short_track.bar_categories << Category.find_by_name("Junior Men")
    short_track.bar_categories << Category.find_by_name("Junior Women")
    short_track.bar_categories << Category.find_by_name("Masters Men")
    short_track.bar_categories << Category.find_by_name("Masters Women")
    short_track.bar_categories << Category.find_by_name("Singlespeed/Fixed")
    short_track.bar_categories << Category.find_by_name("Tandem")
    short_track.bar_categories << Category.find_by_name("Pro Men")
    short_track.bar_categories << Category.find_by_name("Pro Women")
    short_track.bar_categories << Category.find_by_name("Category 2 Men")
    short_track.bar_categories << Category.find_by_name("Category 2 Women")
    short_track.bar_categories << Category.find_by_name("Category 1 Men")
    short_track.bar_categories << Category.find_by_name("Category 1 Women")
    
    Discipline.find(:all, :conditions => "bar is true").each do |discipline|
      discipline.bar_categories << Category.find_by_name("Clydesdale")
    end
    
    if ASSOCIATION.short_name == "obra"
      execute "delete from events where date >= '2010-01-01' and type like '%bar%'"
      OverallBar.calculate!
    end
  end

  def self.down
  end
end<commit_msg>Use Category#find_or_create when setting up BAR categories<commit_after>class UpdateBarFor2010 < ActiveRecord::Migration
  def self.up
    downhill = Discipline[:downhill]
    downhill.bar_categories.clear
    downhill.bar = false
    downhill.save!
    
    short_track = Discipline.create!(:name => "Short Track", :bar => true)
    short_track.bar_categories << Category.find_or_create_by_name("Category 3 Men")
    short_track.bar_categories << Category.find_or_create_by_name("Category 3 Women")
    short_track.bar_categories << Category.find_or_create_by_name("Junior Men")
    short_track.bar_categories << Category.find_or_create_by_name("Junior Women")
    short_track.bar_categories << Category.find_or_create_by_name("Masters Men")
    short_track.bar_categories << Category.find_or_create_by_name("Masters Women")
    short_track.bar_categories << Category.find_or_create_by_name("Singlespeed/Fixed")
    short_track.bar_categories << Category.find_or_create_by_name("Tandem")
    short_track.bar_categories << Category.find_or_create_by_name("Pro Men")
    short_track.bar_categories << Category.find_or_create_by_name("Pro Women")
    short_track.bar_categories << Category.find_or_create_by_name("Category 2 Men")
    short_track.bar_categories << Category.find_or_create_by_name("Category 2 Women")
    short_track.bar_categories << Category.find_or_create_by_name("Category 1 Men")
    short_track.bar_categories << Category.find_or_create_by_name("Category 1 Women")
    
    Discipline.find(:all, :conditions => "bar is true").each do |discipline|
      discipline.bar_categories << Category.find_or_create_by_name("Clydesdale")
    end
    
    if ASSOCIATION.short_name == "obra"
      execute "delete from events where date >= '2010-01-01' and type like '%bar%'"
      OverallBar.calculate!
    end
  end

  def self.down
    Discipline.delete_all "name = 'Short Track'"
  end
end
{'fraction_non_alphanumeric': 0.10589887640449439, 'fraction_numerical': 0.010112359550561797, 'mean_word_length': 4.8665568369028005, 'pattern_counts': {'":': 0, '<': 65, '<?xml version=': 0, '>': 11, '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': '3740970', 'n_tokens_mistral': 1150, 'n_tokens_neox': 1109, 'n_words': 197}