From 71a33ab2e7b2c34ce434943cb84829f28a9039e9 Mon Sep 17 00:00:00 2001
From: Jorrit Schaap <schaap@astron.nl>
Date: Fri, 19 Aug 2016 14:38:16 +0000
Subject: [PATCH] Task #9607: update observation stop time on completing status

---
 .../OTDBtoRATaskStatusPropagator/propagator.py       | 12 ++++++++----
 1 file changed, 8 insertions(+), 4 deletions(-)

diff --git a/SAS/ResourceAssignment/OTDBtoRATaskStatusPropagator/propagator.py b/SAS/ResourceAssignment/OTDBtoRATaskStatusPropagator/propagator.py
index f2c904549c4..07af4960e49 100644
--- a/SAS/ResourceAssignment/OTDBtoRATaskStatusPropagator/propagator.py
+++ b/SAS/ResourceAssignment/OTDBtoRATaskStatusPropagator/propagator.py
@@ -137,10 +137,13 @@ class OTDBtoRATaskStatusPropagator(OTDBBusListener):
     def onObservationCompleting(self, treeId, modificationTime):
         self._update_radb_task_status(treeId, 'completing')
 
-    def _updateStopTime(self, treeId, only_pipelines=False):
+        # otdb adjusts stoptime when aborted,
+        self._updateStopTime(treeId, ['observation'])
+
+    def _updateStopTime(self, treeId, task_types=None):
         radb_task = self.radb.getTask(otdb_id=treeId)
         if radb_task:
-            if only_pipelines and radb_task['type'] != 'pipeline':
+            if task_types and radb_task['type'] not in task_types:
                 return
 
             otdb_task = self.otdb.taskGetTreeInfo(otdb_id=treeId)
@@ -155,13 +158,14 @@ class OTDBtoRATaskStatusPropagator(OTDBBusListener):
 
         # otdb adjusts stoptime when finishing,
         # reflect that in radb for pipelines
-        self._updateStopTime(treeId, only_pipelines=True)
+        self._updateStopTime(treeId, ['pipeline'])
 
     def onObservationAborted(self, treeId, modificationTime):
         self._update_radb_task_status(treeId, 'aborted')
 
         # otdb adjusts stoptime when aborted,
-        self._updateStopTime(treeId, only_pipelines=False)
+        self._updateStopTime(treeId)
+
 
 def main():
     # Check the invocation arguments
-- 
GitLab