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/04/18 09:19:18 UTC

[GitHub] [dolphinscheduler] caishunfeng commented on a diff in pull request #9559: [Bug] [API-9558]fix homepage task instance count method to use submit time to recount

caishunfeng commented on code in PR #9559:
URL: https://github.com/apache/dolphinscheduler/pull/9559#discussion_r851996573


##########
dolphinscheduler-api/src/main/java/org/apache/dolphinscheduler/api/service/impl/DataAnalysisServiceImpl.java:
##########
@@ -165,14 +166,25 @@ private Map<String, Object> countStateByProject(User loginUser, long projectCode
 
         List<ExecuteStatusCount> processInstanceStateCounts = new ArrayList<>();
         Long[] projectCodeArray = projectCode == 0 ? getProjectCodesArrays(loginUser)
-            : new Long[] {projectCode};
+                : new Long[]{projectCode};
 
         if (projectCodeArray.length != 0 || loginUser.getUserType() == UserType.ADMIN_USER) {
             processInstanceStateCounts = instanceStateCounter.apply(start, end, projectCodeArray);
         }
 
         if (processInstanceStateCounts != null) {
             TaskCountDto taskCountResult = new TaskCountDto(processInstanceStateCounts);
+            int recount = 0;
+            for (TaskStateCount taskCountDto : taskCountResult.getTaskCountDtos()) {
+                if (taskCountDto.getCount() == 0) {
+                    //use submit time to recount when 0
+                    //if have any issues with this code should change to specified states 0 8 9 17 not state count is 0
+                    int count = taskInstanceMapper.countTaskInstanceStateByProjectCodesAndState(start, end, projectCodeArray, taskCountDto.getTaskStateType().getCode());

Review Comment:
   Why not query all states at once? Avoid multiple db interactions in the query loop



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