15 lines
517 B
Ruby
15 lines
517 B
Ruby
# Copyright (C) 2024 Manuel Bustillo
|
|
|
|
class TablesArrangementsController < ApplicationController
|
|
def index
|
|
render json: TablesArrangement.all.order(discomfort: :asc).limit(10).as_json(only: %i[id discomfort])
|
|
end
|
|
|
|
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) }
|
|
.then { |result| render json: result }
|
|
end
|
|
end
|