<commit_before>require 'database_cleaner'
require "csv"

DatabaseCleaner.clean_with :truncation

puts "Creating Settings"
Setting.create(key: 'official_level_1_name', value: 'Employés publics')
Setting.create(key: 'official_level_2_name', value: 'Organisation municipale')
Setting.create(key: 'official_level_3_name', value: 'Directeur général')
Setting.create(key: 'official_level_4_name', value: 'Conseiller municipal')
Setting.create(key: 'official_level_5_name', value: 'Le Maire')

Setting.create(key: 'max_ratio_anon_votes_on_debates', value: '50')
Setting.create(key: 'max_votes_for_debate_edit', value: '1000')
Setting.create(key: 'max_votes_for_proposal_edit', value: '1000')
Setting.create(key: 'proposal_code_prefix', value: 'MAD')
Setting.create(key: 'votes_for_proposal_success', value: '5')
Setting.create(key: 'months_to_archive_proposals', value: '12')
Setting.create(key: 'comments_body_max_length', value: '1000')

Setting.create(key: 'twitter_handle', value: '@consul_dev')
Setting.create(key: 'twitter_hashtag', value: '#consul_dev')
Setting.create(key: 'facebook_handle', value: 'consul')
Setting.create(key: 'youtube_handle', value: 'consul')
Setting.create(key: 'blog_url', value: '/blog')
Setting.create(key: 'url', value: 'http://localhost:3000')
Setting.create(key: 'org_name', value: 'Consul')
Setting.create(key: 'place_name', value: 'City')
# Setting.create(key: 'feature.debates', value: "true")
Setting.create(key: 'feature.spending_proposals', value: nil)
Setting.create(key: 'feature.spending_proposal_features.voting_allowed', value: nil)
Setting.create(key: 'feature.budgets', value: "true")
# Setting.create(key: 'feature.twitter_login', value: "true")
# Setting.create(key: 'feature.facebook_login', value: "true")
# Setting.create(key: 'feature.google_login', value: "true")
Setting.create(key: 'feature.signature_sheets', value: "true")
Setting.create(key: 'per_page_code', value: "")
Setting.create(key: 'comments_body_max_length', value: '1000')
Setting.create(key: 'mailer_from_name', value: 'Consul')
Setting.create(key: 'mailer_from_address', value: '<EMAIL>')
Setting.create(key: 'meta_description', value: 'Citizen Participation and Open Government Application')
Setting.create(key: 'meta_keywords', value: 'citizen participation, open government')
Setting.create(key: 'verification_offices_url', value: 'http://oficinas-atencion-ciudadano.url/')
Setting.create(key: 'min_age_to_participate', value: '16')

puts "Creating Geozones"
['Toute la ville', '1er', '2ème', '3ème', '4ème', '5ème'  ].each { |i| Geozone.create(name: "Quartier #{i}", external_code: i.ord, census_code: i.ord) }

puts "Creating Users"

def create_user(email, username = Faker::Name.name)
  pwd = '<PASSWORD>'
  puts "    #{username}"
  User.create!(username: username, email: email, password: <PASSWORD>, password_confirmation: <PASSWORD>, confirmed_at: Time.current, terms_of_service: "1")
end

admin = create_user('<EMAIL>', 'admin')
admin.create_administrator

moderator = create_user('<EMAIL>', 'mod')
moderator.create_moderator

manager = create_user('<EMAIL>', 'manager')
manager.create_manager

valuator = create_user('<EMAIL>', 'valuator')
valuator.create_valuator

level_2 = create_user('<EMAIL>', 'level 2')
level_2.update(residence_verified_at: Time.current, confirmed_phone: Faker::PhoneNumber.phone_number, document_number: "2222222222", document_type: "1" )

verified = create_user('<EMAIL>', 'verified')
verified.update(residence_verified_at: Time.current, confirmed_phone: Faker::PhoneNumber.phone_number, document_type: "1", verified_at: Time.current, document_number: "3333333333")

(1..10).each do |i|
  org_name = Faker::Company.name
  org_user = create_user("<EMAIL>", org_name)
  org_responsible_name = Faker::Name.name
  org = org_user.create_organization(name: org_name, responsible_name: org_responsible_name)

  verified = [true, false].sample
  if verified then
    org.verify
  else
    org.reject
  end
end
<commit_msg>better seed<commit_after>require 'database_cleaner'
require "csv"

DatabaseCleaner.clean_with :truncation

puts "Creating Settings"
Setting.create(key: 'official_level_1_name', value: 'Employés publics')
Setting.create(key: 'official_level_2_name', value: 'Organisation municipale')
Setting.create(key: 'official_level_3_name', value: 'Directeur général')
Setting.create(key: 'official_level_4_name', value: 'Conseiller municipal')
Setting.create(key: 'official_level_5_name', value: 'Le Maire')

Setting.create(key: 'max_ratio_anon_votes_on_debates', value: '50')
Setting.create(key: 'max_votes_for_debate_edit', value: '1000')
Setting.create(key: 'max_votes_for_proposal_edit', value: '1000')
Setting.create(key: 'proposal_code_prefix', value: 'MAD')
Setting.create(key: 'votes_for_proposal_success', value: '5')
Setting.create(key: 'months_to_archive_proposals', value: '12')
Setting.create(key: 'comments_body_max_length', value: '1000')

Setting.create(key: 'twitter_handle', value: '@consul_dev')
Setting.create(key: 'twitter_hashtag', value: '#<PASSWORD>')
Setting.create(key: 'facebook_handle', value: 'consul')
Setting.create(key: 'youtube_handle', value: 'consul')
Setting.create(key: 'blog_url', value: '/blog')
Setting.create(key: 'url', value: 'http://localhost:3000')
Setting.create(key: 'org_name', value: 'Consul')
Setting.create(key: 'place_name', value: 'City')
# Setting.create(key: 'feature.debates', value: "true")
Setting.create(key: 'feature.spending_proposals', value: nil)
Setting.create(key: 'feature.spending_proposal_features.voting_allowed', value: nil)
Setting.create(key: 'feature.budgets', value: "true")
# Setting.create(key: 'feature.twitter_login', value: "true")
# Setting.create(key: 'feature.facebook_login', value: "true")
# Setting.create(key: 'feature.google_login', value: "true")
Setting.create(key: 'feature.signature_sheets', value: "true")
Setting.create(key: 'per_page_code', value: "")
Setting.create(key: 'comments_body_max_length', value: '1000')
Setting.create(key: 'mailer_from_name', value: 'Consul')
Setting.create(key: 'mailer_from_address', value: '<EMAIL>')
Setting.create(key: 'meta_description', value: 'Citizen Participation and Open Government Application')
Setting.create(key: 'meta_keywords', value: 'citizen participation, open government')
Setting.create(key: 'verification_offices_url', value: 'http://oficinas-atencion-ciudadano.url/')
Setting.create(key: 'min_age_to_participate', value: '16')

puts "Creating Geozones"
['Toute la ville', '1er', '2ème', '3ème', '4ème', '5ème'  ].each { |i| Geozone.create(name: "Quartier #{i}", external_code: i.ord, census_code: i.ord) }

puts "Creating Users"

def create_user(email, username = Faker::Name.name)
  pwd = '<PASSWORD>'
  puts "    #{username}"
  User.create!(username: username, email: email, password: <PASSWORD>, password_confirmation: <PASSWORD>, confirmed_at: Time.current, terms_of_service: "1")
end

admin = create_user('<EMAIL>', 'admin')
admin.create_administrator

moderator = create_user('<EMAIL>', 'mod')
moderator.create_moderator

manager = create_user('<EMAIL>', 'manager')
manager.create_manager

valuator = create_user('<EMAIL>', 'valuator')
valuator.create_valuator

level_2 = create_user('<EMAIL>', 'level 2')
level_2.update(residence_verified_at: Time.current, confirmed_phone: Faker::PhoneNumber.phone_number, document_number: "2222222222", document_type: "1" )

verified = create_user('<EMAIL>', 'verified')
verified.update(residence_verified_at: Time.current, confirmed_phone: Faker::PhoneNumber.phone_number, document_type: "1", verified_at: Time.current, document_number: "3333333333")

# création des utilisateurs francçais

valentin = create_user('<EMAIL>', 'valentin')
valentin.update(residence_verified_at: Time.current, confirmed_phone: Faker::PhoneNumber.phone_number, document_type: "1", verified_at: Time.current, document_number: "3333333333")

alain = create_user('<EMAIL>', 'alain')
alain.update(residence_verified_at: Time.current, confirmed_phone: Faker::PhoneNumber.phone_number, document_type: "1", verified_at: Time.current, document_number: "3333333333")

olivier = create_user('<EMAIL>', 'olivier')
olivier.update(residence_verified_at: Time.current, confirmed_phone: Faker::PhoneNumber.phone_number, document_type: "1", verified_at: Time.current, document_number: "3333333333")

virgile = create_user('<EMAIL>', 'virgile')
virgile.update(residence_verified_at: Time.current, confirmed_phone: Faker::PhoneNumber.phone_number, document_type: "1", verified_at: Time.current, document_number: "3333333333")

noe = create_user('<EMAIL>', 'noe')
noe.update(residence_verified_at: Time.current, confirmed_phone: Faker::PhoneNumber.phone_number, document_type: "1", verified_at: Time.current, document_number: "3333333333")

hugo = create_user('<EMAIL>', 'hugo')
hugo.update(residence_verified_at: Time.current, confirmed_phone: Faker::PhoneNumber.phone_number, document_type: "1", verified_at: Time.current, document_number: "3333333333")

(1..10).each do |i|
  org_name = Faker::Company.name
  org_user = create_user("<EMAIL>", org_name)
  org_responsible_name = Faker::Name.name
  org = org_user.create_organization(name: org_name, responsible_name: org_responsible_name)

  verified = [true, false].sample
  if verified then
    org.verify
  else
    org.reject
  end
end

{'fraction_non_alphanumeric': 0.15349037323867915, 'fraction_numerical': 0.021297192642787996, 'mean_word_length': 8.487755102040817, 'pattern_counts': {'":': 0, '<': 32, '<?xml version=': 0, '>': 32, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 10, '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': '6673823', 'n_tokens_mistral': 3291, 'n_tokens_neox': 3165, 'n_words': 635}