From d05db5bd58d4bc4c05d51ce3891a127ac88e1153 Mon Sep 17 00:00:00 2001 From: Jorrit Schaap <schaap@astron.nl> Date: Thu, 2 Sep 2021 20:34:38 +0200 Subject: [PATCH] TMSS-917: adapted and fixed various tests now that we reverted to a single parent TaskBlueprint for a Subtask. --- .../lib/tmss_postgres_listener.py | 74 +++++++++---------- 1 file changed, 37 insertions(+), 37 deletions(-) diff --git a/SAS/TMSS/backend/services/tmss_postgres_listener/lib/tmss_postgres_listener.py b/SAS/TMSS/backend/services/tmss_postgres_listener/lib/tmss_postgres_listener.py index 5e197efa6af..cdc9bed5b68 100644 --- a/SAS/TMSS/backend/services/tmss_postgres_listener/lib/tmss_postgres_listener.py +++ b/SAS/TMSS/backend/services/tmss_postgres_listener/lib/tmss_postgres_listener.py @@ -207,43 +207,43 @@ class TMSSPGListener(PostgresListener): subtask = Subtask.objects.get(id=subtask_id) # check if task is new or changed... If so, send event. - for task_blueprint in subtask.task_blueprints.all(): - task_id = task_blueprint.id - task_cached_properties = {'status': task_blueprint.status, - 'start_time': task_blueprint.start_time, - 'stop_time': task_blueprint.stop_time } - - if task_id not in self._task_cache or self._task_cache[task_id][1] != task_cached_properties: - # send generic updated event - self.onTaskBlueprintUpdated( {'id': task_id}) - - # only send status updated event when the status changed - if task_cached_properties['status'] != self._task_cache.get(task_id, (None, {}))[1].get('status'): - self._sendNotification(TMSS_TASKBLUEPRINT_STATUS_EVENT_PREFIX+'.'+task_cached_properties['status'].capitalize(), - {'id': task_id, 'status': task_cached_properties['status']}) - - # update cache for this task - self._task_cache[task_id] = (datetime.utcnow(), task_cached_properties) - - - # check if scheduling_unit status is new or changed... If so, send event. - scheduling_unit = task_blueprint.scheduling_unit_blueprint - scheduling_unit_id = scheduling_unit.id - scheduling_unit_cached_properties = {'status': scheduling_unit.status, - 'start_time': scheduling_unit.start_time, - 'stop_time': scheduling_unit.stop_time } - - if scheduling_unit_id not in self._scheduling_unit_cache or self._scheduling_unit_cache[scheduling_unit_id][1] != scheduling_unit_cached_properties: - # send generic updated event - self.onSchedulingUnitBlueprintUpdated( {'id': scheduling_unit_id}) - - # only send status updated event when the status changed - if scheduling_unit_cached_properties['status'] != self._scheduling_unit_cache.get(scheduling_unit_id, (None, {}))[1].get('status'): - self._sendNotification(TMSS_SCHEDULINGUNITBLUEPRINT_STATUS_EVENT_PREFIX+'.'+scheduling_unit_cached_properties['status'].capitalize(), - {'id': scheduling_unit_id, 'status': scheduling_unit_cached_properties['status']}) - - # update cache for this task - self._scheduling_unit_cache[scheduling_unit_id] = (datetime.utcnow(), scheduling_unit_cached_properties) + task_blueprint = subtask.task_blueprint + task_id = subtask.task_blueprint.id + task_cached_properties = {'status': task_blueprint.status, + 'start_time': task_blueprint.start_time, + 'stop_time': task_blueprint.stop_time } + + if task_id not in self._task_cache or self._task_cache[task_id][1] != task_cached_properties: + # send generic updated event + self.onTaskBlueprintUpdated( {'id': task_id}) + + # only send status updated event when the status changed + if task_cached_properties['status'] != self._task_cache.get(task_id, (None, {}))[1].get('status'): + self._sendNotification(TMSS_TASKBLUEPRINT_STATUS_EVENT_PREFIX+'.'+task_cached_properties['status'].capitalize(), + {'id': task_id, 'status': task_cached_properties['status']}) + + # update cache for this task + self._task_cache[task_id] = (datetime.utcnow(), task_cached_properties) + + + # check if scheduling_unit status is new or changed... If so, send event. + scheduling_unit = task_blueprint.scheduling_unit_blueprint + scheduling_unit_id = scheduling_unit.id + scheduling_unit_cached_properties = {'status': scheduling_unit.status, + 'start_time': scheduling_unit.start_time, + 'stop_time': scheduling_unit.stop_time } + + if scheduling_unit_id not in self._scheduling_unit_cache or self._scheduling_unit_cache[scheduling_unit_id][1] != scheduling_unit_cached_properties: + # send generic updated event + self.onSchedulingUnitBlueprintUpdated( {'id': scheduling_unit_id}) + + # only send status updated event when the status changed + if scheduling_unit_cached_properties['status'] != self._scheduling_unit_cache.get(scheduling_unit_id, (None, {}))[1].get('status'): + self._sendNotification(TMSS_SCHEDULINGUNITBLUEPRINT_STATUS_EVENT_PREFIX+'.'+scheduling_unit_cached_properties['status'].capitalize(), + {'id': scheduling_unit_id, 'status': scheduling_unit_cached_properties['status']}) + + # update cache for this task + self._scheduling_unit_cache[scheduling_unit_id] = (datetime.utcnow(), scheduling_unit_cached_properties) except Subtask.DoesNotExist: pass -- GitLab