Compare commits
No commits in common. "tables-stats" and "main" have entirely different histories.
tables-sta
...
main
@ -663,4 +663,4 @@ RUBY VERSION
|
|||||||
ruby 3.4.3p32
|
ruby 3.4.3p32
|
||||||
|
|
||||||
BUNDLED WITH
|
BUNDLED WITH
|
||||||
2.7.2
|
2.6.1
|
||||||
|
|||||||
@ -4,28 +4,17 @@
|
|||||||
|
|
||||||
class TablesArrangementsController < ApplicationController
|
class TablesArrangementsController < ApplicationController
|
||||||
def index
|
def index
|
||||||
query = TablesArrangement
|
current_digest = Tables::Distribution.digest(current_tenant)
|
||||||
.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))
|
|
||||||
|
|
||||||
query = query.where(status: params[:status]) if params[:status].present?
|
render json: TablesArrangement
|
||||||
|
.order(valid: :desc)
|
||||||
render json: query
|
.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])
|
.as_json(only: %i[id name discomfort valid status progress])
|
||||||
end
|
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
|
def show
|
||||||
Guest.joins(:seats, :group)
|
Guest.joins(:seats, :group)
|
||||||
.where(seats: { tables_arrangement_id: params[:id] })
|
.where(seats: { tables_arrangement_id: params[:id] })
|
||||||
@ -46,10 +35,6 @@ class TablesArrangementsController < ApplicationController
|
|||||||
|
|
||||||
private
|
private
|
||||||
|
|
||||||
def current_digest
|
|
||||||
@current_digest ||= Tables::Distribution.digest(current_tenant)
|
|
||||||
end
|
|
||||||
|
|
||||||
def format(number:, guests:)
|
def format(number:, guests:)
|
||||||
{
|
{
|
||||||
number: number,
|
number: number,
|
||||||
|
|||||||
@ -40,9 +40,7 @@ Rails.application.routes.draw do
|
|||||||
|
|
||||||
resource :website, only: [:show, :update]
|
resource :website, only: [:show, :update]
|
||||||
|
|
||||||
resources :tables_arrangements, only: %i[index show create] do
|
resources :tables_arrangements, only: %i[index show create]
|
||||||
get :stats, on: :collection
|
|
||||||
end
|
|
||||||
resources :summary, only: :index
|
resources :summary, only: :index
|
||||||
resources :invitations, only: %i[show index create update destroy] do
|
resources :invitations, only: %i[show index create update destroy] do
|
||||||
post :email, on: :collection
|
post :email, on: :collection
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user