Expose tables via API
This commit is contained in:
parent
62a7af6db3
commit
be9f61e03e
@ -3,12 +3,34 @@
|
||||
class TablesArrangementsController < ApplicationController
|
||||
def index
|
||||
@tables_arrangements = TablesArrangement.all.order(discomfort: :asc).limit(10)
|
||||
|
||||
respond_to do |format|
|
||||
format.html
|
||||
format.json { render json: @tables_arrangements }
|
||||
end
|
||||
end
|
||||
|
||||
def show
|
||||
@tables_arrangement = TablesArrangement.find(params[:id])
|
||||
@seats = @tables_arrangement.seats
|
||||
.includes(guest: %i[affinity_groups unbreakable_bonds])
|
||||
.group_by(&:table_number)
|
||||
@seats = @tables_arrangement.seats.group_by(&:table_number)
|
||||
|
||||
respond_to do |format|
|
||||
format.html
|
||||
format.json do
|
||||
render json: {
|
||||
tables: @seats.map do |table_number, seats|
|
||||
{
|
||||
table_number: table_number,
|
||||
guests: seats.map do |seat|
|
||||
{
|
||||
guest: seat.guest,
|
||||
group: seat.guest.group,
|
||||
}
|
||||
end
|
||||
}
|
||||
end
|
||||
}
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
Loading…
x
Reference in New Issue
Block a user