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/10 02:06:03 UTC

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

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


##########
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:
   #in the method of DateUtils#format2Duration .when endTime is null will return new Date. i mean that maybe we can use 
   ```java
    DateUtils.format2Duration(processInstance.getStartTime(), processInstance.getEndTime())
   ``` 
   instead of
    ```java
   String duration = processInstance.getState() != null && processInstance.getState().isFinished() ?
                       DateUtils.format2Duration(processInstance.getStartTime(), processInstance.getEndTime()) :
                       DateUtils.format2Duration(processInstance.getStartTime(), new Date()); 
   ```



-- 
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