Recreate simulations whenever a guest changes their attendance #85

Merged
bustikiller merged 8 commits from simulations-lifecycle into main 2024-11-03 12:51:14 +00:00
2 changed files with 13 additions and 1 deletions
Showing only changes of commit 35bf272ac8 - Show all commits

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