<commit_before># This file should contain all the record creation needed to seed the database with its default values.
# The data can then be loaded with the rake db:seed (or created alongside the db with db:setup).
#
# Examples:
#
#   cities = City.create([{ :name => 'Chicago' }, { :name => 'Copenhagen' }])
#   Mayor.create(:name => 'Daley', :city => cities.first)

#a DB connection
db = ActiveRecord::Base.connection

#downcase server names
#TODO: add a validation on the name
Server.all.each do |server|
  server.update_attribute("name", server.name.downcase)
end

#fill ApplicationInstance if needed
if ApplicationInstance.count == 0 && Application.count > 0
  Application.all.each do |application|
    ApplicationInstance.find_or_create_by_name_and_application_id("prod", application.id)
    ApplicationInstance.find_or_create_by_name_and_application_id("ecole", application.id) if application.read_attribute(:pe).include?("E")
  end
end

#migrate application servers old links
if db.table_exists?("applications_servers")
  results = Server.connection.execute("SELECT application_id, server_id from applications_servers;").to_a
  results.each do |result|
    application_id, server_id = result
    prod_instance = ApplicationInstance.find_by_name_and_application_id("prod", application_id)
    if prod_instance && !prod_instance.server_ids.include?(server_id) && m=Server.find_by_id(server_id)
      prod_instance.servers << m
      prod_instance.save
    end
  end
end

#set default authentication method
if ApplicationInstance.where("authentication_method" => nil).count > 0
  ApplicationInstance.all.each do |app_instance|
    if app_instance.name == "prod" && app_instance.application.cerbere
      app_instance.update_attribute("authentication_method", "cerbere")
    else
      app_instance.update_attribute("authentication_method", "none")
    end
  end
end
<commit_msg>Removed seed data for automatically creating ApplicationInstance's<commit_after># This file should contain all the record creation needed to seed the database with its default values.
# The data can then be loaded with the rake db:seed (or created alongside the db with db:setup).
#
# Examples:
#
#   cities = City.create([{ :name => 'Chicago' }, { :name => 'Copenhagen' }])
#   Mayor.create(:name => 'Daley', :city => cities.first)

#a DB connection
db = ActiveRecord::Base.connection

#downcase server names
#TODO: add a validation on the name
Server.all.each do |server|
  server.update_attribute("name", server.name.downcase)
end

#migrate application servers old links
if db.table_exists?("applications_servers")
  results = Server.connection.execute("SELECT application_id, server_id from applications_servers;").to_a
  results.each do |result|
    application_id, server_id = result
    prod_instance = ApplicationInstance.find_by_name_and_application_id("prod", application_id)
    if prod_instance && !prod_instance.server_ids.include?(server_id) && m=Server.find_by_id(server_id)
      prod_instance.servers << m
      prod_instance.save
    end
  end
end

#set default authentication method
if ApplicationInstance.where("authentication_method" => nil).count > 0
  ApplicationInstance.all.each do |app_instance|
    if app_instance.name == "prod" && app_instance.application.cerbere
      app_instance.update_attribute("authentication_method", "cerbere")
    else
      app_instance.update_attribute("authentication_method", "none")
    end
  end
end

{'fraction_non_alphanumeric': 0.1018867924528302, 'fraction_numerical': 0.0011611030478955006, 'mean_word_length': 5.231464737793852, 'pattern_counts': {'":': 0, '<': 7, '<?xml version=': 0, '>': 16, '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': '4061580', 'n_tokens_mistral': 1004, 'n_tokens_neox': 1008, 'n_words': 270}