<commit_before>namespace :umlautdb do
  desc "Loads in initial set of irrelvant_sites and relevant_sites"
  task :load_sites => :environment do
    require 'active_record/fixtures'
    
    # Load a starting set of relevant_sites and irrelevant_sites
    # Magic from Rails book to load a fixture in a migration
    fixed_data_dir = File.join(RAILS_ROOT, "db", "orig_fixed_data")
  
  
    if ( RelevantSite.find(:first).nil? )
      puts "Loading a suggested starting list of relevant_sites."
      Fixtures.create_fixtures(fixed_data_dir, "relevant_sites")
    else
      puts "relevant_sites is not empty, so not loading initial data set."
    end
      
    if ( IrrelevantSite.find(:first).nil? )
      puts "Loading a suggested starting list of irrelevant_sites."
      Fixtures.create_fixtures(fixed_data_dir, "irrelevant_sites")
    else
      puts "irrelevant_sites is not empty, so not loading initial data set."
    end
  end

  desc "Loads in standard Rails service_type_values."
  task :load_service_type_values => :environment do
    require 'yaml'
  
    # Load in starting set of ServiceTypeValue.
    puts "Loading service type values from db/orig_fixed_data/service_type_values.yml"
    ServiceTypeValue.enumeration_model_updates_permitted = true
    
    fixed_data_dir = File.join(RAILS_ROOT, "db", "orig_fixed_data")
    service_type_values = YAML.load_file( File::join(fixed_data_dir, 'service_type_values.yml') )
    
    service_type_values.each_pair do |name, hash|
      #require 'ruby-debug'
      #debugger
      existing = ServiceTypeValue.find(:first, :conditions=>["id = ?", hash['id'] ])
      if (existing)
        puts "ServiceTypeValue #{value['name']} NOT inserted, as id #{value['id']} already exists in db."
      else
        # Add the YAML label to the hash, for initialization of our AR without
        # needing to repeat ourselves. 
        hash[:name] = name
        new_value = ServiceTypeValue.new( hash )
        new_value.id = hash['id']
        new_value.save!
      end      
    end
    ServiceTypeValue.enumeration_model_updates_permitted = false    <commit_msg>fixed bug in task, sorry<commit_after>namespace :umlautdb do
  desc "Loads in initial set of irrelvant_sites and relevant_sites"
  task :load_sites => :environment do
    require 'active_record/fixtures'
    
    # Load a starting set of relevant_sites and irrelevant_sites
    # Magic from Rails book to load a fixture in a migration
    fixed_data_dir = File.join(RAILS_ROOT, "db", "orig_fixed_data")
  
  
    if ( RelevantSite.find(:first).nil? )
      puts "Loading a suggested starting list of relevant_sites."
      Fixtures.create_fixtures(fixed_data_dir, "relevant_sites")
    else
      puts "relevant_sites is not empty, so not loading initial data set."
    end
      
    if ( IrrelevantSite.find(:first).nil? )
      puts "Loading a suggested starting list of irrelevant_sites."
      Fixtures.create_fixtures(fixed_data_dir, "irrelevant_sites")
    else
      puts "irrelevant_sites is not empty, so not loading initial data set."
    end
  end

  desc "Loads in standard Rails service_type_values."
  task :load_service_type_values => :environment do
    require 'yaml'
  
    # Load in starting set of ServiceTypeValue.
    puts "Loading service type values from db/orig_fixed_data/service_type_values.yml"
    ServiceTypeValue.enumeration_model_updates_permitted = true
    
    fixed_data_dir = File.join(RAILS_ROOT, "db", "orig_fixed_data")
    service_type_values = YAML.load_file( File::join(fixed_data_dir, 'service_type_values.yml') )
    
    service_type_values.each_pair do |name, hash|
      existing = ServiceTypeValue.find(:first, :conditions=>["id = ?", hash['id'] ])
      if (existing)
        puts "ServiceTypeValue #{hash['name']} NOT inserted, as id #{hash['id']} already exists in db."
      else
        # Add the YAML label to the hash, for initialization of our AR without
        # needing to repeat ourselves. 
        hash[:name] = name
        new_value = ServiceTypeValue.new( hash )
        new_value.id = hash['id']
        new_value.save!
      end      
    end
    ServiceTypeValue.enumeration_model_updates_permitted = false    
{'fraction_non_alphanumeric': 0.08394943954209397, 'fraction_numerical': 0.0, 'mean_word_length': 3.3015384615384615, 'pattern_counts': {'":': 0, '<': 3, '<?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': '625982', 'n_tokens_mistral': 1295, 'n_tokens_neox': 1251, 'n_words': 365}