Define a new endpoint to create simulations
All checks were successful
Run unit tests / copyright_notice (pull_request) Successful in 1m3s
Run unit tests / rubocop (pull_request) Successful in 1m28s
Run unit tests / check-licenses (pull_request) Successful in 1m33s
Run unit tests / unit_tests (pull_request) Successful in 1m4s
Run unit tests / build-static-assets (pull_request) Successful in 12m29s

This commit is contained in:
Manuel Bustillo 2025-01-26 13:36:25 +01:00
parent 707f05d81c
commit 998c0f43f3
3 changed files with 22 additions and 2 deletions

View File

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

View File

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

View File

@ -26,6 +26,19 @@ RSpec.describe 'tables_arrangements' do
end end
regular_api_responses regular_api_responses
end 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 end
path '/{slug}/tables_arrangements/{id}' do path '/{slug}/tables_arrangements/{id}' do