Restart simulations whenever a guest changes their invitation status
Some checks failed
Build Nginx-based docker image / build-static-assets (pull_request) Waiting to run
Add copyright notice / copyright_notice (pull_request) Successful in 4m39s
Run unit tests / unit_tests (pull_request) Failing after 22m29s

This commit is contained in:
Manuel Bustillo 2024-11-03 09:25:50 +01:00
parent 50a5c90728
commit 35bf272ac8
2 changed files with 13 additions and 1 deletions

View File

@ -26,7 +26,7 @@ class GuestsController < ApplicationController
end end
def bulk_update def bulk_update
Guest.where(id: params[:guest_ids]).update!(params.require(:properties).permit(:status)) Guests::UpdateUseCase.new(guest_ids: params[:guest_ids], params: params.require(:properties).permit(:status)).call
render json: {}, status: :ok render json: {}, status: :ok
end end
end end

View File

@ -0,0 +1,12 @@
module Guests
class UpdateUseCase
def initialize(guest_ids:, params:)
Guest.where(id: guest_ids).update!(params)
# TODO: Not all status transitions may require a table re-arrangement
TablesArrangement.delete_all
ActiveJob.perform_all_later(50.times.map { TableSimulatorJob.new })
end
end
end