updated
This commit is contained in:
parent
637edfadd4
commit
b4b9f97690
|
|
@ -348,29 +348,28 @@ class Event2Occupant(CrudCollection):
|
|||
)
|
||||
|
||||
@classmethod
|
||||
def get_event_codes(cls, build_living_space_id) -> list:
|
||||
db = cls.new_session()
|
||||
def get_event_codes(cls, build_living_space_id, db_session) -> list:
|
||||
occupant_events = cls.filter_all(
|
||||
cls.build_living_space_id == build_living_space_id,
|
||||
db=db,
|
||||
db=db_session,
|
||||
).data
|
||||
active_event_ids = Service2Events.filter_all_system(
|
||||
Service2Events.service_id.in_(
|
||||
[event.event_service_id for event in occupant_events]
|
||||
),
|
||||
db=db,
|
||||
db=db_session,
|
||||
).data
|
||||
active_events = Events.filter_all(
|
||||
Events.id.in_([event.event_id for event in active_event_ids]),
|
||||
db=db,
|
||||
db=db_session,
|
||||
).data
|
||||
if extra_events := Event2OccupantExtra.filter_all(
|
||||
Event2OccupantExtra.build_living_space_id == build_living_space_id,
|
||||
db=db,
|
||||
db=db_session,
|
||||
).data:
|
||||
events_extra = Events.filter_all(
|
||||
Events.id.in_([event.event_id for event in extra_events]),
|
||||
db=db,
|
||||
db=db_session,
|
||||
).data
|
||||
active_events.extend(events_extra)
|
||||
return [event.function_code for event in active_events]
|
||||
|
|
|
|||
|
|
@ -1,6 +1,6 @@
|
|||
import arrow
|
||||
|
||||
from typing import Any, Union
|
||||
from typing import Any
|
||||
from fastapi import Request
|
||||
|
||||
from ApiLayers.ApiLibrary.common.line_number import get_line_number_for_error
|
||||
|
|
@ -12,6 +12,7 @@ from ApiLayers.ApiValidations.Response.default_response import (
|
|||
EndpointNotAcceptableResponse,
|
||||
EndpointBadRequestResponse,
|
||||
)
|
||||
from ApiLayers.AllConfigs.Redis.configs import RedisAuthKeys
|
||||
from ApiLayers.ErrorHandlers import HTTPExceptionApi
|
||||
from ApiLayers.Schemas import (
|
||||
BuildLivingSpace,
|
||||
|
|
@ -29,9 +30,9 @@ from ApiLayers.Schemas import (
|
|||
Users,
|
||||
UsersTokens,
|
||||
)
|
||||
|
||||
from Events.base_request_model import TokenDictType, BaseRouteModel
|
||||
from Services.RedisService.Actions.actions import RedisActions
|
||||
from ApiLayers.AllConfigs.Redis.configs import RedisAuthKeys
|
||||
|
||||
|
||||
class Handlers:
|
||||
|
|
@ -158,7 +159,7 @@ class Handlers:
|
|||
|
||||
# Get reachable events
|
||||
reachable_event_codes = Event2Occupant.get_event_codes(
|
||||
build_living_space_id=selected_build_living_space.id
|
||||
build_living_space_id=selected_build_living_space.id, db_session=db
|
||||
)
|
||||
occupant_type = OccupantTypes.filter_one_system(
|
||||
OccupantTypes.id == selected_build_living_space.occupant_type_id,
|
||||
|
|
|
|||
|
|
@ -3,19 +3,17 @@ Validation function handlers
|
|||
"""
|
||||
|
||||
from typing import Dict, Any, Optional
|
||||
from fastapi import Request
|
||||
|
||||
from ApiLayers.AllConfigs.Redis.configs import (
|
||||
RedisCategoryKeys,
|
||||
RedisValidationKeysAction,
|
||||
RedisCategoryPageInfoKeysAction,
|
||||
)
|
||||
from ApiLayers.ApiLibrary.common.line_number import get_line_number_for_error
|
||||
from ApiLayers.ErrorHandlers.Exceptions.api_exc import HTTPExceptionApi
|
||||
|
||||
from Services.RedisService.Actions.actions import RedisActions
|
||||
from Events.base_request_model import BaseRouteModel
|
||||
|
||||
from config import ValidationsConfig
|
||||
from ApiLayers.AllConfigs.Api.config import ValidationsConfig
|
||||
|
||||
|
||||
class ValidateBase:
|
||||
|
|
|
|||
Loading…
Reference in New Issue