Manuel Bustillo
2147d7ad5e
All checks were successful
Run unit tests / rubocop (push) Successful in 27s
Run unit tests / check-licenses (push) Successful in 32s
Run unit tests / copyright_notice (push) Successful in 36s
Run unit tests / unit_tests (push) Successful in 1m22s
Run unit tests / build-static-assets (push) Successful in 10m9s
## Why The current way of creating and deleting simulations doesn't scale for big instances. We cannot generate 50 simulations every time a guest confirms attendance, and we should not delete existing valuable simulations. For example, if a guest confirms attendance and declines right after, previously generated simulations should still be valid. ## What In this PR we are introducing a series of changes that make simulations management easier: 1. We're removing the automatic creation of simulations. 2. Simulations are not removed anymore, neither manually nor automatically. 3. A new endpoint has been defined to create simulations on demand. 4. A digest property has been defined to determine whether a simulation is still valid (meaning there have not been any change in the list of guests involved). Reviewed-on: #222 Co-authored-by: Manuel Bustillo <bustikiller@bustikiller.com> Co-committed-by: Manuel Bustillo <bustikiller@bustikiller.com>
100 lines
3.1 KiB
Ruby
100 lines
3.1 KiB
Ruby
# Copyright (C) 2024-2025 LibreWeddingPlanner contributors
|
|
|
|
# frozen_string_literal: true
|
|
|
|
require 'swagger_helper'
|
|
|
|
RSpec.describe 'tables_arrangements' do
|
|
path '/{slug}/tables_arrangements' do
|
|
get('list tables arrangements') do
|
|
tags 'Tables Arrangements'
|
|
produces 'application/json'
|
|
parameter Swagger::Schema::SLUG
|
|
response(200, 'successful') do
|
|
schema type: :array,
|
|
items: {
|
|
type: :object,
|
|
required: %i[id name discomfort],
|
|
properties: {
|
|
id: { type: :string, format: :uuid },
|
|
name: { type: :string },
|
|
discomfort: { type: :integer },
|
|
valid: { type: :boolean }
|
|
}
|
|
}
|
|
xit
|
|
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
|
|
get('show tables arrangement') do
|
|
tags 'Tables Arrangements'
|
|
produces 'application/json'
|
|
parameter Swagger::Schema::SLUG
|
|
parameter Swagger::Schema::ID
|
|
response(200, 'successful') do
|
|
schema type: :object,
|
|
required: %i[id tables],
|
|
properties: {
|
|
id: { type: :string, format: :uuid },
|
|
tables: {
|
|
|
|
type: :array,
|
|
items: {
|
|
type: :object,
|
|
required: %i[number guests discomfort],
|
|
properties: {
|
|
number: { type: :integer },
|
|
guests: {
|
|
type: :array,
|
|
items: {
|
|
type: :object,
|
|
required: %i[id name color],
|
|
properties: {
|
|
id: { type: :string, format: :uuid },
|
|
name: { type: :string },
|
|
color: { type: :string }
|
|
}
|
|
}
|
|
},
|
|
discomfort: {
|
|
type: :object,
|
|
required: %i[discomfort breakdown],
|
|
properties: {
|
|
discomfort: { type: :number },
|
|
breakdown: {
|
|
type: :object,
|
|
required: %i[table_size_penalty cohesion_penalty],
|
|
properties: {
|
|
table_size_penalty: { type: :number },
|
|
cohesion_penalty: { type: :number }
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
xit
|
|
end
|
|
regular_api_responses
|
|
end
|
|
end
|
|
end
|