Refine arrangement detail endpoint
This commit is contained in:
parent
d4c1e5aab0
commit
612cb9a789
@ -7,8 +7,10 @@ class TablesArrangementsController < ApplicationController
|
||||
|
||||
def show
|
||||
Seat.joins(:guest).where(tables_arrangement_id: params[:id])
|
||||
.pluck(:table_number, Arel.sql("guests.first_name || ' ' ||guests.last_name "))
|
||||
.group_by(&:first).transform_values { |table| table.map(&:last) }
|
||||
.pluck(:table_number, Arel.sql("guests.first_name || ' ' || guests.last_name "), 'guests.id')
|
||||
.group_by(&:first)
|
||||
.transform_values { |table| table.map { |(_, name, id)| { id:, name: } } }
|
||||
.map { |number, guests| { number:, guests: } }
|
||||
.then { |result| render json: result }
|
||||
end
|
||||
end
|
||||
|
Loading…
x
Reference in New Issue
Block a user