appender events and applications are updated
This commit is contained in:
@@ -43,6 +43,12 @@ EventsEndpointEventClusterBindOccupantExtra.add_event(EventBindOccupantExtraEven
|
||||
EventsEndpointRouterCluster.set_event_cluster(EventsEndpointEventClusterListAvailable)
|
||||
EventsEndpointRouterCluster.set_event_cluster(EventsEndpointEventClusterListAppended)
|
||||
EventsEndpointRouterCluster.set_event_cluster(EventsEndpointEventClusterRegisterService)
|
||||
EventsEndpointRouterCluster.set_event_cluster(EventsEndpointEventClusterUnregisterService)
|
||||
EventsEndpointRouterCluster.set_event_cluster(EventsEndpointEventClusterBindEmployeeExtra)
|
||||
EventsEndpointRouterCluster.set_event_cluster(EventsEndpointEventClusterBindOccupantExtra)
|
||||
EventsEndpointRouterCluster.set_event_cluster(
|
||||
EventsEndpointEventClusterUnregisterService
|
||||
)
|
||||
EventsEndpointRouterCluster.set_event_cluster(
|
||||
EventsEndpointEventClusterBindEmployeeExtra
|
||||
)
|
||||
EventsEndpointRouterCluster.set_event_cluster(
|
||||
EventsEndpointEventClusterBindOccupantExtra
|
||||
)
|
||||
|
||||
@@ -72,22 +72,33 @@ def events_list_available_callable(list_options: PaginateOnly):
|
||||
List available events with pagination and filtering options
|
||||
"""
|
||||
list_options = PaginateOnly(**list_options.model_dump())
|
||||
service_uu_id = list_options.query.get('service_uu_id__ilike', None)
|
||||
service_uu_id = list_options.query.get("service_uu_id__ilike", None)
|
||||
if not service_uu_id:
|
||||
return {
|
||||
"message": "MSG0003-PARAM-MISSING",
|
||||
"data": list_options.query,
|
||||
"completed": False,
|
||||
}
|
||||
list_options.query.pop("service_uu_id__ilike", None)
|
||||
list_options.query.pop("service_uu_id", None)
|
||||
with Events.new_session() as db_session:
|
||||
service2events = Service2Events.filter_all(*Service2Events.convert(list_options.query), db=db_session)
|
||||
already_events = [service_to_event.event_id for service_to_event in service2events.data]
|
||||
list_options.query.pop('service_uu_id__ilike', None)
|
||||
list_options.query.pop('service_uu_id', None)
|
||||
service2events = Service2Events.filter_all(
|
||||
*Service2Events.convert({"service_uu_id__ilike": service_uu_id}),
|
||||
db=db_session,
|
||||
)
|
||||
already_events = [
|
||||
service_to_event.event_id for service_to_event in service2events.data
|
||||
]
|
||||
if list_options.query:
|
||||
events_list = Events.filter_all(*Events.convert(list_options.query), Events.id.not_in(already_events), db=db_session)
|
||||
events_list = Events.filter_all(
|
||||
*Events.convert(list_options.query),
|
||||
Events.id.not_in(already_events),
|
||||
db=db_session,
|
||||
)
|
||||
else:
|
||||
events_list = Events.filter_all(Events.id.not_in(already_events), db=db_session)
|
||||
events_list = Events.filter_all(
|
||||
Events.id.not_in(already_events), db=db_session
|
||||
)
|
||||
pagination = Pagination(data=events_list)
|
||||
pagination.change(**list_options.model_dump())
|
||||
pagination_result = PaginationResult(data=events_list, pagination=pagination)
|
||||
@@ -105,22 +116,34 @@ def events_list_appended_callable(list_options: PaginateOnly):
|
||||
List appended events with pagination and filtering options
|
||||
"""
|
||||
list_options = PaginateOnly(**list_options.model_dump())
|
||||
service_uu_id = list_options.query.get('service_uu_id__ilike', None)
|
||||
service_uu_id = list_options.query.get("service_uu_id__ilike", None)
|
||||
if not service_uu_id:
|
||||
return {
|
||||
"message": "MSG0003-PARAM-MISSING",
|
||||
"data": list_options.query,
|
||||
"completed": False,
|
||||
}
|
||||
list_options.query.pop("service_uu_id__ilike", None)
|
||||
list_options.query.pop("service_uu_id", None)
|
||||
with Events.new_session() as db_session:
|
||||
service2events = Service2Events.filter_all(*Service2Events.convert(list_options.query), db=db_session)
|
||||
already_events = [service_to_event.event_id for service_to_event in service2events.data]
|
||||
list_options.query.pop('service_uu_id__ilike', None)
|
||||
list_options.query.pop('service_uu_id', None)
|
||||
service2events = Service2Events.filter_all(
|
||||
*Service2Events.convert({"service_uu_id__ilike": service_uu_id}),
|
||||
db=db_session,
|
||||
)
|
||||
already_events = [
|
||||
service_to_event.event_id for service_to_event in service2events.data
|
||||
]
|
||||
|
||||
if list_options.query:
|
||||
events_list = Events.filter_all(*Events.convert(list_options.query), Events.id.in_(already_events), db=db_session)
|
||||
events_list = Events.filter_all(
|
||||
*Events.convert(list_options.query),
|
||||
Events.id.in_(already_events),
|
||||
db=db_session,
|
||||
)
|
||||
else:
|
||||
events_list = Events.filter_all(Events.id.in_(already_events), db=db_session)
|
||||
events_list = Events.filter_all(
|
||||
Events.id.in_(already_events), db=db_session
|
||||
)
|
||||
pagination = Pagination(data=events_list)
|
||||
pagination.change(**list_options.model_dump())
|
||||
pagination_result = PaginationResult(data=events_list, pagination=pagination)
|
||||
@@ -139,10 +162,9 @@ def event_register_service_callable(data: Any):
|
||||
"""
|
||||
with Events.new_session() as db_session:
|
||||
event = Events.filter_one_system(
|
||||
Events.uu_id == data.event_uu_id,
|
||||
db=db_session
|
||||
Events.uu_id == data.event_uu_id, db=db_session
|
||||
)
|
||||
print('event', event.data)
|
||||
print("event", event.data)
|
||||
if not event.data:
|
||||
return {
|
||||
"message": "MSG0003-NOT-FOUND",
|
||||
@@ -150,10 +172,9 @@ def event_register_service_callable(data: Any):
|
||||
"completed": False,
|
||||
}
|
||||
service = Services.filter_one_system(
|
||||
Services.uu_id == data.service_uu_id,
|
||||
db=db_session
|
||||
Services.uu_id == data.service_uu_id, db=db_session
|
||||
)
|
||||
print('service', service.data)
|
||||
print("service", service.data)
|
||||
if not service.data:
|
||||
return {
|
||||
"message": "MSG0003-NOT-FOUND",
|
||||
@@ -169,10 +190,10 @@ def event_register_service_callable(data: Any):
|
||||
service_id=service.data.id,
|
||||
event_id=event.data.id,
|
||||
is_confirmed=True,
|
||||
service_uu_id=str(service.data.uu_id),
|
||||
service_uu_id=str(service.data.uu_id),
|
||||
event_uu_id=str(event.data.uu_id),
|
||||
)
|
||||
print('service_to_event', service_to_event)
|
||||
print("service_to_event", service_to_event)
|
||||
if not service_to_event.meta_data.created:
|
||||
return {
|
||||
"message": "MSG0003-ALREADY-FOUND",
|
||||
@@ -214,8 +235,8 @@ def event_unregister_service_callable(data: Any):
|
||||
"completed": False,
|
||||
}
|
||||
service_to_event = Service2Events.filter_one_system(
|
||||
Service2Events.service_id==service.data.id,
|
||||
Service2Events.event_id==event.data.id,
|
||||
Service2Events.service_id == service.data.id,
|
||||
Service2Events.event_id == event.data.id,
|
||||
db=db_session,
|
||||
)
|
||||
if not service_to_event.data:
|
||||
|
||||
Reference in New Issue
Block a user