alchemy functions updated
This commit is contained in:
@@ -68,8 +68,11 @@ class Modules(CrudCollection):
|
||||
is_default_module = mapped_column(Boolean, server_default="0")
|
||||
|
||||
def retrieve_services(self):
|
||||
services = Services.filter_all(Services.module_id == self.id)
|
||||
if not services.count:
|
||||
services = Services.filter_all(
|
||||
Services.module_id == self.id,
|
||||
*Services.valid_record_args(Services)
|
||||
).data
|
||||
if not services:
|
||||
self.raise_http_exception(
|
||||
status_code="HTTP_404_NOT_FOUND",
|
||||
error_case="RECORD_NOT_FOUND",
|
||||
@@ -78,7 +81,7 @@ class Modules(CrudCollection):
|
||||
"module_uu_id": str(self.uu_id),
|
||||
},
|
||||
)
|
||||
return services.data
|
||||
return services
|
||||
|
||||
__table_args__ = ({"comment": "Modules Information"},)
|
||||
|
||||
@@ -143,9 +146,14 @@ class Event2Employee(CrudCollection):
|
||||
|
||||
@classmethod
|
||||
def get_event_id_by_employee_id(cls, employee_id) -> (list, list):
|
||||
active_events = cls.filter_all(cls.employee_id == employee_id)
|
||||
active_events = cls.filter_all(
|
||||
cls.employee_id == employee_id, *cls.valid_record_args(cls)
|
||||
)
|
||||
active_events_id = [event.event_id for event in active_events.data]
|
||||
active_events = Events.filter_all(Events.id.in_(active_events_id))
|
||||
active_events = Events.filter_all(
|
||||
Events.id.in_(active_events_id),
|
||||
*Events.valid_record_args(Events)
|
||||
)
|
||||
active_events_uu_id = [str(event.uu_id) for event in active_events.data]
|
||||
return active_events_id, active_events_uu_id
|
||||
|
||||
|
||||
Reference in New Issue
Block a user