Redo simulations lifecycle #222

Merged
bustikiller merged 6 commits from table-arrangements-guest-digest into main 2025-01-26 12:53:22 +00:00
3 changed files with 22 additions and 2 deletions
Showing only changes of commit 998c0f43f3 - Show all commits

View File

@ -7,10 +7,11 @@ class TablesArrangementsController < ApplicationController
current_digest = Tables::Distribution.digest(current_tenant)
render json: TablesArrangement
.order(valid: :desc)
.order(discomfort: :asc)
.select(:id, :name, :discomfort)
.select("digest = '#{current_digest}'::uuid as valid")
.limit(3)
.limit(20)
.as_json(only: %i[id name discomfort valid])
end
@ -23,6 +24,12 @@ class TablesArrangementsController < ApplicationController
.then { |result| render json: { id: params[:id], tables: result } }
end
def create
TableSimulatorJob.perform_later(current_tenant.id)
render json: {}, status: :created
end
private
def format(number:, guests:)

View File

@ -37,7 +37,7 @@ Rails.application.routes.draw do
resources :expenses, only: %i[index create update destroy] do
get :summary, on: :collection
end
resources :tables_arrangements, only: %i[index show]
resources :tables_arrangements, only: %i[index show create]
resources :summary, only: :index
root to: redirect("/%{slug}")

View File

@ -26,6 +26,19 @@ RSpec.describe 'tables_arrangements' do
end
regular_api_responses
end
post('create tables arrangement') do
tags 'Tables Arrangements'
produces 'application/json'
parameter Swagger::Schema::SLUG
response(201, 'successful') do
schema type: :object,
required: [],
properties: {}
xit
end
regular_api_responses
end
end
path '/{slug}/tables_arrangements/{id}' do