sqlalchemy updated

This commit is contained in:
2025-01-21 19:35:34 +03:00
parent 8e34497c80
commit 87e5f5ab06
54 changed files with 2549 additions and 540 deletions

View File

@@ -278,6 +278,42 @@ class Event2Employee(CrudCollection):
active_events.extend(events_extra)
return [event.function_code for event in active_events]
@classmethod
def get_event_endpoints(cls, employee_id: int) -> list:
from Schemas import EndpointRestriction
db = cls.new_session()
employee_events = cls.filter_all(
cls.employee_id == employee_id,
db=db,
).data
active_event_ids = Service2Events.filter_all(
Service2Events.service_id.in_(
[event.event_service_id for event in employee_events]
),
db=db,
system=True,
).data
active_events = Events.filter_all(
Events.id.in_([event.event_id for event in active_event_ids]),
db=db,
).data
if extra_events := Event2EmployeeExtra.filter_all(
Event2EmployeeExtra.employee_id == employee_id,
db=db,
).data:
events_extra = Events.filter_all(
Events.id.in_([event.event_id for event in extra_events]),
db=db,
).data
active_events.extend(events_extra)
endpoint_restrictions = EndpointRestriction.filter_all(
EndpointRestriction.id.in_(
[event.endpoint_id for event in active_events]
),
db=db,
).data
return [event.endpoint_name for event in endpoint_restrictions]
class Event2Occupant(CrudCollection):
"""
@@ -342,6 +378,41 @@ class Event2Occupant(CrudCollection):
active_events.extend(events_extra)
return [event.function_code for event in active_events]
@classmethod
def get_event_endpoints(cls, build_living_space_id) -> list:
from Schemas import EndpointRestriction
db = cls.new_session()
occupant_events = cls.filter_all(
cls.build_living_space_id == build_living_space_id,
db=db,
).data
active_event_ids = Service2Events.filter_all(
Service2Events.service_id.in_(
[event.event_service_id for event in occupant_events]
),
db=db,
system=True,
).data
active_events = Events.filter_all(
Events.id.in_([event.event_id for event in active_event_ids]),
db=db,
).data
if extra_events := Event2OccupantExtra.filter_all(
Event2OccupantExtra.build_living_space_id == build_living_space_id,
db=db,
).data:
events_extra = Events.filter_all(
Events.id.in_([event.event_id for event in extra_events]),
db=db,
).data
active_events.extend(events_extra)
endpoint_restrictions = EndpointRestriction.filter_all(
EndpointRestriction.id.in_(
[event.endpoint_id for event in active_events]
),
db=db,
).data
return [event.endpoint_name for event in endpoint_restrictions]
class ModulePrice(CrudCollection):
"""