people endpoints and super user events built

This commit is contained in:
2025-04-13 17:28:20 +03:00
parent c3b7556e7e
commit 9a4696af77
363 changed files with 3270 additions and 264289 deletions

View File

@@ -288,15 +288,14 @@ class Event2Employee(CrudCollection):
)
@classmethod
def get_event_codes(cls, employee_id: int, db) -> dict[str : list[str]]:
def get_event_codes(cls, employee_id: int, db) -> dict[str:str]:
employee_events = cls.filter_all(
cls.employee_id == employee_id,
db=db,
).data
active_event_ids = Service2Events.filter_all_system(
Service2Events.service_id.in_(
[event.event_service_id for event in employee_events]
),
service_ids = list(set([event.event_service_id for event in employee_events]))
active_event_ids = Service2Events.filter_all(
Service2Events.service_id.in_(service_ids),
db=db,
).data
active_events = Events.filter_all(
@@ -314,10 +313,10 @@ class Event2Employee(CrudCollection):
active_events.extend(events_extra)
events_dict = {}
for event in active_events:
if event.endpoint_code in events_dict:
events_dict[event.endpoint_code].append(event.function_code)
if not event.endpoint_code in events_dict:
events_dict[str(event.endpoint_code)] = str(event.function_code)
else:
events_dict[event.endpoint_code] = [event.function_code]
ValueError("Duplicate event code found for single endpoint")
return events_dict
@@ -355,15 +354,14 @@ class Event2Occupant(CrudCollection):
)
@classmethod
def get_event_codes(cls, build_living_space_id: int, db) -> dict[str : list[str]]:
def get_event_codes(cls, build_living_space_id: int, db) -> dict[str:str]:
occupant_events = cls.filter_all(
cls.build_living_space_id == build_living_space_id,
db=db,
).data
service_ids = list(set([event.event_service_id for event in occupant_events]))
active_event_ids = Service2Events.filter_all_system(
Service2Events.service_id.in_(
[event.event_service_id for event in occupant_events]
),
Service2Events.service_id.in_(service_ids),
db=db,
).data
active_events = Events.filter_all(
@@ -381,10 +379,10 @@ class Event2Occupant(CrudCollection):
active_events.extend(events_extra)
events_dict = {}
for event in active_events:
if event.endpoint_code in events_dict:
events_dict[event.endpoint_code].append(event.function_code)
if not event.endpoint_code in events_dict:
events_dict[str(event.endpoint_code)] = str(event.function_code)
else:
events_dict[event.endpoint_code] = [event.function_code]
ValueError("Duplicate event code found for single endpoint")
return events_dict