15672: Fix NaN runtime
authorPeter Amstutz <peter.amstutz@curii.com>
Wed, 8 Jan 2020 21:39:16 +0000 (16:39 -0500)
committerPeter Amstutz <peter.amstutz@curii.com>
Wed, 8 Jan 2020 21:39:16 +0000 (16:39 -0500)
Arvados-DCO-1.1-Signed-off-by: Peter Amstutz <peter.amstutz@curii.com>

src/store/processes/process.ts

index ab8093b856c4c259b1bab8992e98293444f7ac78..400d77cfc88ee38942e46a5a1a6692e5a9ee82a2 100644 (file)
@@ -56,10 +56,20 @@ export const getSubprocesses = (uuid: string) => (resources: ResourcesState) =>
     return [];
 };
 
-export const getProcessRuntime = ({ container }: Process) =>
-    container
-        ? getTimeDiff(container.finishedAt || '', container.startedAt || '')
-        : 0;
+export const getProcessRuntime = ({ container }: Process) => {
+    if (container) {
+        if (container.startedAt === null) {
+            return 0;
+        }
+        if (container.finishedAt === null) {
+            // Count it from now
+            return new Date().getTime() - new Date(container.startedAt).getTime();
+        }
+        return getTimeDiff(container.finishedAt, container.startedAt);
+    } else {
+        return 0;
+    }
+};
 
 export const getProcessStatusColor = (status: string, { customs, palette }: ArvadosTheme) => {
     switch (status) {