fix(events): guard booking_occupancy when booking table missing
Admin eunit suites call event_to_json without Mnesia booking table; catch list_by_event failures and treat as free.
This commit is contained in:
@@ -345,9 +345,16 @@ event_to_json(Event) ->
|
||||
}.
|
||||
|
||||
%% @doc Активная занятость слота для сетки commercial (Studio aggregate).
|
||||
%% Safe if Mnesia booking table is not ready (admin/unit tests without full schema).
|
||||
-spec booking_occupancy(#event{}) -> free | pending | confirmed.
|
||||
booking_occupancy(#event{id = EventId, start_time = Start}) ->
|
||||
{ok, Bookings} = core_booking:list_by_event(EventId),
|
||||
Bookings =
|
||||
try
|
||||
{ok, List} = core_booking:list_by_event(EventId),
|
||||
List
|
||||
catch
|
||||
_:_ -> []
|
||||
end,
|
||||
Now = calendar:universal_time(),
|
||||
lists:foldl(
|
||||
fun(#booking{status = confirmed}, _Acc) ->
|
||||
|
||||
Reference in New Issue
Block a user