From 5cb3526e3075c7893d6a5cabce0cc34cc94b1e5c Mon Sep 17 00:00:00 2001 From: PArmingol <pablo.armingolrobles@telefonica.com> Date: Tue, 6 Feb 2024 16:06:14 +0100 Subject: [PATCH] code cleanup --- src/context/service/database/Context.py | 5 +++-- src/device/service/DeviceServiceServicerImpl.py | 1 - src/webui/service/device/routes.py | 4 +--- 3 files changed, 4 insertions(+), 6 deletions(-) diff --git a/src/context/service/database/Context.py b/src/context/service/database/Context.py index 5cefae316..403dcd232 100644 --- a/src/context/service/database/Context.py +++ b/src/context/service/database/Context.py @@ -87,7 +87,6 @@ def context_set(db_engine : Engine, messagebroker : MessageBroker, request : Con 'context_uuid': context_uuid, 'context_name': context_name, 'created_at' : now, - 'updated_at' : now, }] @@ -97,7 +96,6 @@ def context_set(db_engine : Engine, messagebroker : MessageBroker, request : Con index_elements=[ContextModel.context_uuid], set_=dict( context_name = stmt.excluded.context_name, - updated_at = stmt.excluded.updated_at, ) ) @@ -106,6 +104,9 @@ def context_set(db_engine : Engine, messagebroker : MessageBroker, request : Con return updated_at > created_at updated = run_transaction(sessionmaker(bind=db_engine), callback) + event_type = EventTypeEnum.EVENTTYPE_UPDATE if updated else EventTypeEnum.EVENTTYPE_CREATE + context_id = json_context_id(context_uuid) + notify_event_context(messagebroker, event_type, context_id) return ContextId(**context_id) def context_delete(db_engine : Engine, messagebroker : MessageBroker, request : ContextId) -> Empty: diff --git a/src/device/service/DeviceServiceServicerImpl.py b/src/device/service/DeviceServiceServicerImpl.py index f7c1a3c8e..eeffdd7b0 100644 --- a/src/device/service/DeviceServiceServicerImpl.py +++ b/src/device/service/DeviceServiceServicerImpl.py @@ -232,7 +232,6 @@ class DeviceServiceServicerImpl(DeviceServiceServicer): device_id = context_client.SetDevice(device) device = context_client.GetDevice(device_id) - if request.device_operational_status != DeviceOperationalStatusEnum.DEVICEOPERATIONALSTATUS_UNDEFINED: device.device_operational_status = request.device_operational_status diff --git a/src/webui/service/device/routes.py b/src/webui/service/device/routes.py index 220bb2462..1f805cd9e 100644 --- a/src/webui/service/device/routes.py +++ b/src/webui/service/device/routes.py @@ -63,14 +63,12 @@ def add(): for key, _ in DeviceOperationalStatusEnum.DESCRIPTOR.values_by_name.items(): form.operational_status.choices.append( (DeviceOperationalStatusEnum.Value(key), key.replace('DEVICEOPERATIONALSTATUS_', ''))) - form.device_type.choices = [] # items for Device Type field form.device_type.choices = [] for device_type in DeviceTypeEnum: if device_type: - form.device_type.choices.append((device_type.value,device_type.value)) - + form.device_type.choices.append((device_type.value,device_type.value)) if form.validate_on_submit(): device_obj = Device() # Device UUID: -- GitLab