You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@aurora.apache.org by ma...@apache.org on 2014/05/14 00:04:36 UTC

git commit: Fixed duration calculation in the job page.

Repository: incubator-aurora
Updated Branches:
  refs/heads/master 653d581e2 -> f837a7dfe


Fixed duration calculation in the job page.

Testing Done:
Tested locally on laptop. Attached screenshot.

Bugs closed: AURORA-411

Reviewed at https://reviews.apache.org/r/21354/


Project: http://git-wip-us.apache.org/repos/asf/incubator-aurora/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-aurora/commit/f837a7df
Tree: http://git-wip-us.apache.org/repos/asf/incubator-aurora/tree/f837a7df
Diff: http://git-wip-us.apache.org/repos/asf/incubator-aurora/diff/f837a7df

Branch: refs/heads/master
Commit: f837a7dfe7d52e2826261a05eadbbce2a49cde89
Parents: 653d581
Author: Suman Karumuri <ma...@apache.org>
Authored: Tue May 13 15:01:12 2014 -0700
Committer: Suman Karumuri <sk...@twitter.com>
Committed: Tue May 13 15:01:12 2014 -0700

----------------------------------------------------------------------
 .../aurora/scheduler/http/ui/js/controllers.js    | 18 +++++++++++-------
 1 file changed, 11 insertions(+), 7 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-aurora/blob/f837a7df/src/main/resources/org/apache/aurora/scheduler/http/ui/js/controllers.js
----------------------------------------------------------------------
diff --git a/src/main/resources/org/apache/aurora/scheduler/http/ui/js/controllers.js b/src/main/resources/org/apache/aurora/scheduler/http/ui/js/controllers.js
index 768c4fe..4a83e1d 100644
--- a/src/main/resources/org/apache/aurora/scheduler/http/ui/js/controllers.js
+++ b/src/main/resources/org/apache/aurora/scheduler/http/ui/js/controllers.js
@@ -426,7 +426,7 @@ auroraUIControllers.controller('JobController',
         statusMessage: latestTaskEvent.message,
         host: task.assignedTask.slaveHost || '',
         latestActivity: _.isEmpty(sortedTaskEvents) ? 0 : latestTaskEvent.timestamp,
-        duration: getDuration(sortedTaskEvents, isActive),
+        duration: getDuration(sortedTaskEvents),
         isActive: isActive,
         taskId: task.assignedTask.taskId,
         taskEvents: summarizeTaskEvents(sortedTaskEvents),
@@ -435,16 +435,20 @@ auroraUIControllers.controller('JobController',
       };
     }
 
-    function getDuration(sortedTaskEvents, isActive) {
-      if (!isActive || _.isEmpty(sortedTaskEvents)) {
-        return 0;
-      }
-
+    function getDuration(sortedTaskEvents) {
       var runningTaskEvent = _.find(sortedTaskEvents, function (taskEvent) {
         return taskEvent.status === ScheduleStatus.RUNNING;
       });
 
-      return runningTaskEvent ? _.last(sortedTaskEvents).timestamp - runningTaskEvent.timestamp : 0;
+      if (runningTaskEvent) {
+        var nextEvent = sortedTaskEvents[_.indexOf(sortedTaskEvents, runningTaskEvent) + 1];
+
+        return nextEvent
+          ? nextEvent.timestamp - runningTaskEvent.timestamp
+          : moment().valueOf() - runningTaskEvent.timestamp;
+      }
+
+      return 0;
     }
 
     function summarizeTaskEvents(taskEvents) {