tested appender service to events
This commit is contained in:
@@ -49,21 +49,27 @@ class EventCluster:
|
||||
endpoint_uu_id=str(to_save_endpoint.uu_id),
|
||||
is_confirmed=True,
|
||||
db=db_session,
|
||||
include_args=[
|
||||
Events.function_code,
|
||||
Events.function_class,
|
||||
Events.endpoint_code,
|
||||
Events.endpoint_uu_id,
|
||||
]
|
||||
)
|
||||
event_to_save_database = Events.find_or_create(**event_dict_to_save)
|
||||
if event_to_save_database.meta_data.created:
|
||||
print(f"UUID: {event_to_save_database.uu_id} event is saved to {to_save_endpoint.uu_id}")
|
||||
event_found = Events.filter_one(
|
||||
Events.function_code == event_dict_to_save["function_code"],
|
||||
db=db_session,
|
||||
).data
|
||||
if event_found:
|
||||
event_found.update(**event_dict_to_save)
|
||||
event_found.save(db=db_session)
|
||||
else:
|
||||
event_to_save_database.update(**event_dict_to_save)
|
||||
if event_to_save_database.meta_data.updated:
|
||||
print(f"UUID: {event_to_save_database.uu_id} event is updated to {to_save_endpoint.uu_id}")
|
||||
event_to_save_database.save(db=db_session)
|
||||
event_to_save_database = Events.find_or_create(
|
||||
**event_dict_to_save,
|
||||
include_args=[
|
||||
Events.function_code,
|
||||
Events.function_class,
|
||||
Events.endpoint_code,
|
||||
Events.endpoint_uu_id,
|
||||
]
|
||||
)
|
||||
if event_to_save_database.meta_data.created:
|
||||
print(f"UUID: {event_to_save_database.uu_id} event is saved to {to_save_endpoint.uu_id}")
|
||||
event_to_save_database.save(db=db_session)
|
||||
|
||||
def match_event(self, event_key: str) -> "Event":
|
||||
"""
|
||||
|
||||
@@ -23,17 +23,24 @@ class RouteRegisterController:
|
||||
for route_method in [
|
||||
method.lower() for method in getattr(route, "methods")
|
||||
]:
|
||||
restriction = EndpointRestriction.find_or_create(
|
||||
add_or_update_dict = dict(
|
||||
endpoint_method=route_method,
|
||||
endpoint_name=route_path,
|
||||
endpoint_desc=route_summary.replace("_", " "),
|
||||
endpoint_function=route_summary,
|
||||
operation_uu_id=operation_id, # UUID of the endpoint
|
||||
operation_uu_id=operation_id,
|
||||
is_confirmed=True,
|
||||
db=db_session,
|
||||
)
|
||||
if restriction.meta_data.created:
|
||||
restriction.save(db=db_session)
|
||||
endpoint_restriction_found = EndpointRestriction.filter_one_system(
|
||||
EndpointRestriction.operation_uu_id == operation_id, db=db_session,
|
||||
).data
|
||||
if endpoint_restriction_found:
|
||||
endpoint_restriction_found.update(**add_or_update_dict, db=db_session)
|
||||
endpoint_restriction_found.save(db=db_session)
|
||||
else:
|
||||
restriction = EndpointRestriction.find_or_create(**add_or_update_dict, db=db_session)
|
||||
if restriction.meta_data.created:
|
||||
restriction.save(db=db_session)
|
||||
|
||||
def register_routes(self):
|
||||
for router in self.router_list:
|
||||
|
||||
Reference in New Issue
Block a user