wedding-planner/db/seeds.rb

99 lines
3.7 KiB
Ruby
Raw Normal View History

2025-01-27 20:22:21 +01:00
# frozen_string_literal: true
2025-01-23 21:34:23 +00:00
# Copyright (C) 2024-2025 LibreWeddingPlanner contributors
2025-01-27 20:42:31 +01:00
NUMBER_OF_GUESTS = 200
2024-07-11 20:00:55 +02:00
ActsAsTenant.without_tenant do
Wedding.delete_all
end
2024-11-30 19:24:59 +01:00
2024-12-07 23:43:21 +01:00
wedding = Wedding.create!(slug: :default)
2024-12-02 09:04:48 +01:00
ActsAsTenant.with_tenant(wedding) do
2025-01-27 20:22:21 +01:00
[
{ name: 'Photographer', amount: 3000, pricing_type: 'fixed' },
{ name: 'Country house', amount: 6000, pricing_type: 'fixed' },
{ name: 'Catering', amount: 200, pricing_type: 'per_person' },
{ name: 'Flowers', amount: 500, pricing_type: 'fixed' },
{ name: 'Band', amount: 1000, pricing_type: 'fixed' },
{ name: 'Wedding planner', amount: 2000, pricing_type: 'fixed' },
{ name: 'Dress', amount: 1000, pricing_type: 'fixed' },
{ name: 'Suit', amount: 500, pricing_type: 'fixed' },
{ name: 'Rings', amount: 1000, pricing_type: 'fixed' },
{ name: 'Makeup', amount: 200, pricing_type: 'fixed' },
{ name: 'Hair', amount: 200, pricing_type: 'fixed' },
{ name: 'Transportation', amount: 3000, pricing_type: 'fixed' },
{ name: 'Invitations', amount: 200, pricing_type: 'fixed' },
{ name: 'Cake', amount: 500, pricing_type: 'fixed' }
].then { Expense.insert_all!(it) }
2024-11-30 19:24:59 +01:00
2024-11-30 20:06:36 +01:00
Group.create!(name: "Jim's guests", icon: 'pi pi-heart').tap do |parent|
parent.children.create!(name: "Jim's family", icon: 'pi pi-users').tap do |family|
family.children.create!(name: "Jim's close family", icon: 'pi pi-home')
family.children.create!(name: "Jim's cousins", icon: 'pi pi-home')
family.children.create!(name: "Jim's relatives", icon: 'pi pi-home')
end
parent.children.create!(name: "Jim's friends", icon: 'pi pi-bullseye')
parent.children.create!(name: "Jim's work", icon: 'pi pi-desktop').tap do |work|
work.children.create!(name: "Jim's besties at work", icon: 'pi pi-briefcase')
end
2024-08-11 17:26:43 +02:00
end
2024-11-30 20:06:36 +01:00
Group.create!(name: "Pam's guests", icon: 'pi pi-heart-fill').tap do |parent|
parent.children.create!(name: "Pam's family", icon: 'pi pi-users').tap do |family|
family.children.create!(name: "Pam's close family", icon: 'pi pi-home')
family.children.create!(name: "Pam's cousins", icon: 'pi pi-home')
family.children.create!(name: "Pam's relatives", icon: 'pi pi-home')
end
parent.children.create!(name: "Pam's friends", icon: 'pi pi-bullseye')
parent.children.create!(name: "Pam's work", icon: 'pi pi-desktop').tap do |work|
work.children.create!(name: "Pam's besties at work", icon: 'pi pi-briefcase')
end
end
2024-08-11 17:26:43 +02:00
2024-11-30 20:06:36 +01:00
Group.create!(name: 'Common guests', icon: 'pi pi-users').tap do |parent|
parent.children.create!(name: 'College friends', icon: 'pi pi-calculator')
parent.children.create!(name: 'High school friends', icon: 'pi pi-crown')
parent.children.create!(name: 'Childhood friends', icon: 'pi pi-envelope')
end
2024-11-30 20:06:36 +01:00
groups = Group.all
2025-01-27 20:22:21 +01:00
NUMBER_OF_GUESTS.times.map do |i|
{
2024-11-30 20:06:36 +01:00
name: Faker::Name.name,
phone: Faker::PhoneNumber.cell_phone,
2025-01-27 20:22:21 +01:00
group_id: groups.sample.id,
2025-01-27 20:08:28 +01:00
status: Guest.statuses.keys.sample,
2025-01-27 20:22:21 +01:00
}
end.then { Guest.insert_all!(it) }
2024-11-10 09:49:08 +01:00
Group.includes(:guests).each do |group|
guests = group.guests.potential.to_a
while guests.any?
invitation = Invitation.create!
guests.shift(rand(1..3)).each do |guest|
guest.update!(invitation:)
end
end
end
# TODO: Clean up invitations with no guests
ActiveJob.perform_all_later(3.times.map { TableSimulatorJob.new(wedding.id) })
2024-11-10 09:49:08 +01:00
2025-01-27 20:22:21 +01:00
"red".dup.paint.palette.triad(as: :hex).zip(Group.roots).each { |(color, group)| group.update!(color: color.paint.desaturate(40)) }
2024-11-30 20:06:36 +01:00
Group.roots.each(&:colorize_children)
User.create!(
email: 'development@example.com',
confirmed_at: Time.zone.now,
password: 'supersecretpassword',
2025-01-27 20:22:21 +01:00
password_confirmation: 'supersecretpassword'
)
2024-11-30 20:06:36 +01:00
end