You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@dolphinscheduler.apache.org by GitBox <gi...@apache.org> on 2022/10/12 02:21:54 UTC

[GitHub] [dolphinscheduler] ruanwenjun commented on a diff in pull request #12264: [Fix-#11669][Workflow Instance Page] Fix the duration in Workflow Instance page.

ruanwenjun commented on code in PR #12264:
URL: https://github.com/apache/dolphinscheduler/pull/12264#discussion_r992920496


##########
dolphinscheduler-api/src/main/java/org/apache/dolphinscheduler/api/service/impl/ProcessInstanceServiceImpl.java:
##########
@@ -320,8 +320,11 @@ public Result queryProcessInstanceList(User loginUser, long projectCode, long pr
         }
 
         for (ProcessInstance processInstance : processInstances) {
-            processInstance.setDuration(
-                    DateUtils.format2Duration(processInstance.getStartTime(), processInstance.getEndTime()));
+            // if processInstance is running, the endTime should be the current time
+            String duration = processInstance.getState() != null && processInstance.getState().isFinished() ?
+                    DateUtils.format2Duration(processInstance.getStartTime(), processInstance.getEndTime()) :
+                    DateUtils.format2Duration(processInstance.getStartTime(), new Date());

Review Comment:
   Can we move these code in a utils, `WorkflowUtils.getWorkflowInstanceDuration(ProcessInstance processInstance)`?



##########
dolphinscheduler-common/src/main/java/org/apache/dolphinscheduler/common/utils/DateUtils.java:
##########
@@ -353,6 +353,9 @@ public static String format2Duration(Date start, Date end) {
         if (end == null) {
             end = new Date();
         }
+        if (start.after(end)) {

Review Comment:
   This is an unexpected case, we need to log a warning here.



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@dolphinscheduler.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org