Compare commits
No commits in common. "3e6afcc0487d90de26e8f97c99df15d838e8589d" and "40f89ae179b8852d6f4d9e3df2eb4d4b102c6e07" have entirely different histories.
3e6afcc048
...
40f89ae179
@ -9,7 +9,7 @@ class GuestsController < ApplicationController
|
|||||||
render json: Guest.includes(:group)
|
render json: Guest.includes(:group)
|
||||||
.left_joins(:group)
|
.left_joins(:group)
|
||||||
.order('groups.name' => :asc, name: :asc)
|
.order('groups.name' => :asc, name: :asc)
|
||||||
.as_json(only: %i[id name status invitation_id], include: { group: { only: %i[id name] } })
|
.as_json(only: %i[id name status], include: { group: { only: %i[id name] } })
|
||||||
end
|
end
|
||||||
|
|
||||||
def create
|
def create
|
||||||
|
17
db/seeds.rb
17
db/seeds.rb
@ -60,29 +60,18 @@ ActsAsTenant.with_tenant(wedding) do
|
|||||||
|
|
||||||
groups = Group.all
|
groups = Group.all
|
||||||
|
|
||||||
|
invitations = ([{}] * (NUMBER_OF_GUESTS * 0.8)).then { Invitation.insert_all!(it) }.rows.flatten
|
||||||
|
|
||||||
NUMBER_OF_GUESTS.times.map do |i|
|
NUMBER_OF_GUESTS.times.map do |i|
|
||||||
{
|
{
|
||||||
name: Faker::Name.name,
|
name: Faker::Name.name,
|
||||||
phone: Faker::PhoneNumber.cell_phone,
|
phone: Faker::PhoneNumber.cell_phone,
|
||||||
group_id: groups.sample.id,
|
group_id: groups.sample.id,
|
||||||
status: Guest.statuses.keys.sample,
|
status: Guest.statuses.keys.sample,
|
||||||
|
invitation_id: invitations[i]
|
||||||
}
|
}
|
||||||
end.then { Guest.insert_all!(it) }
|
end.then { Guest.insert_all!(it) }
|
||||||
|
|
||||||
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) })
|
ActiveJob.perform_all_later(3.times.map { TableSimulatorJob.new(wedding.id) })
|
||||||
|
|
||||||
"red".dup.paint.palette.triad(as: :hex).zip(Group.roots).each { |(color, group)| group.update!(color: color.paint.desaturate(40)) }
|
"red".dup.paint.palette.triad(as: :hex).zip(Group.roots).each { |(color, group)| group.update!(color: color.paint.desaturate(40)) }
|
||||||
|
Loading…
x
Reference in New Issue
Block a user