-
Notifications
You must be signed in to change notification settings - Fork 4
Create random data to test groups
Astrid Varga edited this page Sep 3, 2020
·
8 revisions
require "securerandom"
def random_level
rand(10) % 2 == 0 ? 0 : 1
end
def random_os
["mac", "windows", "linux"].sample
end
def random_gender
rand(10) % 2 == 0 ? "female" : "male"
end
def random_first_time_coaching
rand(10) % 2 == 0
end
event = Event.create(
name: "test event",
place: "office",
scheduled_at: Time.now + 4.weeks,
installation_get_together_date: Time.now + 4.weeks - 1.day,
application_start: Time.now,
application_end: Time.now + 2.weeks,
confirmation_date: Time.now + 3.weeks,
start_time: "09:00",
end_time: "17:00"
)
50.times do |n|
language_en = [true, false].sample
language_de = language_en == false ? true : [true, false].sample
Application.create(
event_id: event.id,
name: "applicant #{n}",
email: "applicant#{n}@email.com",
level: random_level,
os: random_os,
language_en: language_en,
language_de: language_de,
state: :application_selected,
attendance_confirmed: true,
attended: true,
sequence_number: n,
random_id: SecureRandom.hex(12),
female: true,
read_coc: true
)
end
20.times do |n|
language_en = [true, false].sample
language_de = language_en == false ? true : [true, false].sample
user = User.create(
email: "coach#{n}@email.com",
admin: false,
is_blocked: false,
password: "password"
)
coach = Coach.create(
user_id: user.id,
name: "coach#{n}",
language_en: language_en,
language_de: language_de,
gender: random_gender,
notifications: true
)
CoachApplication.create(
coach_id: coach.id,
event_id: event.id,
installationparty: true,
workshopday: true,
lightningtalk: "inspiring talk",
notes: "hello",
state: "approved",
lightningtalk_approved: true,
contacted_at: Time.now
)
end