Compare commits

..

No commits in common. "tables-stats" and "main" have entirely different histories.

3 changed files with 9 additions and 26 deletions

View File

@ -663,4 +663,4 @@ RUBY VERSION
ruby 3.4.3p32
BUNDLED WITH
2.7.2
2.6.1

View File

@ -4,28 +4,17 @@
class TablesArrangementsController < ApplicationController
def index
query = TablesArrangement
.order(valid: :desc)
.order(discomfort: :asc)
.select(:id, :name, :discomfort, :status, :progress)
.select("digest = '#{current_digest}'::uuid OR discomfort IS NULL as valid")
.limit((params[:limit].presence&.to_i || 20).clamp(1..20))
current_digest = Tables::Distribution.digest(current_tenant)
query = query.where(status: params[:status]) if params[:status].present?
render json: query
render json: TablesArrangement
.order(valid: :desc)
.order(discomfort: :asc)
.select(:id, :name, :discomfort, :status, :progress)
.select("digest = '#{current_digest}'::uuid OR discomfort IS NULL as valid")
.limit(20)
.as_json(only: %i[id name discomfort valid status progress])
end
def stats
scope = TablesArrangement.where('digest = ?::uuid OR discomfort IS NULL', current_digest)
render json: {
count: scope.group(:status).count,
in_progress: scope.where(status: :in_progress).limit(10).order(progress: :desc).pluck(:progress)
}
end
def show
Guest.joins(:seats, :group)
.where(seats: { tables_arrangement_id: params[:id] })
@ -46,10 +35,6 @@ class TablesArrangementsController < ApplicationController
private
def current_digest
@current_digest ||= Tables::Distribution.digest(current_tenant)
end
def format(number:, guests:)
{
number: number,

View File

@ -40,9 +40,7 @@ Rails.application.routes.draw do
resource :website, only: [:show, :update]
resources :tables_arrangements, only: %i[index show create] do
get :stats, on: :collection
end
resources :tables_arrangements, only: %i[index show create]
resources :summary, only: :index
resources :invitations, only: %i[show index create update destroy] do
post :email, on: :collection