Return-Path: X-Original-To: apmail-aurora-commits-archive@minotaur.apache.org Delivered-To: apmail-aurora-commits-archive@minotaur.apache.org Received: from mail.apache.org (hermes.apache.org [140.211.11.3]) by minotaur.apache.org (Postfix) with SMTP id DE44A111E0 for ; Tue, 13 May 2014 22:04:58 +0000 (UTC) Received: (qmail 16282 invoked by uid 500); 13 May 2014 22:04:58 -0000 Delivered-To: apmail-aurora-commits-archive@aurora.apache.org Received: (qmail 16251 invoked by uid 500); 13 May 2014 22:04:58 -0000 Mailing-List: contact commits-help@aurora.incubator.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: dev@aurora.incubator.apache.org Delivered-To: mailing list commits@aurora.incubator.apache.org Received: (qmail 16244 invoked by uid 99); 13 May 2014 22:04:58 -0000 Received: from athena.apache.org (HELO athena.apache.org) (140.211.11.136) by apache.org (qpsmtpd/0.29) with ESMTP; Tue, 13 May 2014 22:04:58 +0000 X-ASF-Spam-Status: No, hits=-2000.7 required=5.0 tests=ALL_TRUSTED,RP_MATCHES_RCVD X-Spam-Check-By: apache.org Received: from [140.211.11.3] (HELO mail.apache.org) (140.211.11.3) by apache.org (qpsmtpd/0.29) with SMTP; Tue, 13 May 2014 22:04:57 +0000 Received: (qmail 10477 invoked by uid 99); 13 May 2014 22:04:37 -0000 Received: from tyr.zones.apache.org (HELO tyr.zones.apache.org) (140.211.11.114) by apache.org (qpsmtpd/0.29) with ESMTP; Tue, 13 May 2014 22:04:37 +0000 Received: by tyr.zones.apache.org (Postfix, from userid 65534) id D7ED28B68B4; Tue, 13 May 2014 22:04:36 +0000 (UTC) Content-Type: text/plain; charset="us-ascii" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit From: mansu@apache.org To: commits@aurora.incubator.apache.org Message-Id: <931ef0f51ab74901a7bb3973a8d0c337@git.apache.org> X-Mailer: ASF-Git Admin Mailer Subject: git commit: Fixed duration calculation in the job page. Date: Tue, 13 May 2014 22:04:36 +0000 (UTC) X-Virus-Checked: Checked by ClamAV on apache.org 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 Authored: Tue May 13 15:01:12 2014 -0700 Committer: Suman Karumuri 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) {