<commit_before>module FakeGeo
  class << self

    def geo_deviation
      scale = 0.2
      r = rand(1000) / (1000.0 / scale)
      r -= scale / 2
      r
    end

    def set_stub
      Geocoder.configure(lookup: :test)
      Geocoder::Lookup::Test.set_default_stub(
        [
          {
            'latitude'     => Settings.mapview.default_latitude  + geo_deviation,
            'longitude'    => Settings.mapview.default_longitude + geo_deviation,
          }
        ]
      )
    end

  end
end

namespace :FosterFork do

  desc 'add fake users for testing'
  task add_fake_users: :environment do |_t, _args|
    ActiveRecord::Base.transaction do
      100.times do
        FakeGeo::set_stub
        password = <PASSWORD>

        u = User.create!(name: Faker::Name.name,
                         email: Faker::Internet.email,
                         newsletter: Faker::Boolean.boolean,
                         phone: Faker::PhoneNumber.phone_number,
                         zip: Faker::Address.zip_code,
                         country: Settings.countries.shuffle.first,
                         password: password,
                         terms: "1")
        puts "Created user: #{u.name} <#{u.email}>, password: #{password}"
      end<commit_msg>fake_data: stub out mail delivery method<commit_after>module FakeGeo
  class << self

    def geo_deviation
      scale = 0.2
      r = rand(1000) / (1000.0 / scale)
      r -= scale / 2
      r
    end

    def set_stub
      Geocoder.configure(lookup: :test)
      Geocoder::Lookup::Test.set_default_stub(
        [
          {
            'latitude'     => Settings.mapview.default_latitude  + geo_deviation,
            'longitude'    => Settings.mapview.default_longitude + geo_deviation,
          }
        ]
      )
    end

  end
end

namespace :FosterFork do

  desc 'add fake users for testing'
  task add_fake_users: :environment do |_t, _args|
    ActiveRecord::Base.transaction do
      ApplicationMailer.delivery_method = :test

      100.times do
        FakeGeo::set_stub
        password = <PASSWORD>.password

        u = User.create(name: Faker::Name.name,
                        email: Faker::Internet.email,
                        newsletter: Faker::Boolean.boolean,
                        phone: Faker::PhoneNumber.phone_number,
                        zip: Faker::Address.zip_code,
                        country: Settings.countries.shuffle.first,
                        password: password,
                        confirmed_at: Time.now,
                        terms: "1")
        puts "Created user: #{u.name} <#{u.email}>, password: #{password}"
      end
{'fraction_non_alphanumeric': 0.09694454922670691, 'fraction_numerical': 0.012070916635231988, 'mean_word_length': 1.6414342629482073, 'pattern_counts': {'":': 0, '<': 11, '<?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': '205244', 'n_tokens_mistral': 803, 'n_tokens_neox': 755, 'n_words': 164}