2024-11-03 08:31:58 +00:00
|
|
|
# Copyright (C) 2024 Manuel Bustillo
|
|
|
|
|
2024-11-03 09:25:50 +01:00
|
|
|
module Guests
|
|
|
|
class UpdateUseCase
|
2024-11-03 13:56:10 +01:00
|
|
|
private attr_reader :guest_ids, :params
|
2024-11-03 09:25:50 +01:00
|
|
|
def initialize(guest_ids:, params:)
|
2024-11-03 13:56:10 +01:00
|
|
|
@guest_ids = guest_ids
|
|
|
|
@params = params
|
|
|
|
end
|
|
|
|
|
|
|
|
def call
|
2024-11-03 09:25:50 +01:00
|
|
|
Guest.where(id: guest_ids).update!(params)
|
|
|
|
|
|
|
|
# TODO: Not all status transitions may require a table re-arrangement
|
2024-11-11 07:43:42 +01:00
|
|
|
return unless params.key?(:status)
|
|
|
|
|
2024-11-03 09:25:50 +01:00
|
|
|
TablesArrangement.delete_all
|
|
|
|
|
|
|
|
ActiveJob.perform_all_later(50.times.map { TableSimulatorJob.new })
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|