qingwli commented on code in PR #15193:
URL: 
https://github.com/apache/dolphinscheduler/pull/15193#discussion_r1400292543


##########
dolphinscheduler-api/src/main/java/org/apache/dolphinscheduler/api/controller/DataAnalysisController.java:
##########
@@ -107,35 +91,30 @@ public Result<TaskCountDto> 
countTaskState(@Parameter(hidden = true) @RequestAtt
     @GetMapping(value = "/process-state-count")
     @ResponseStatus(HttpStatus.OK)
     @ApiException(COUNT_PROCESS_INSTANCE_STATE_ERROR)
-    public Result<TaskCountDto> countProcessInstanceState(@Parameter(hidden = 
true) @RequestAttribute(value = Constants.SESSION_USER) User loginUser,
-                                                          @RequestParam(value 
= "startDate", required = false) String startDate,
-                                                          @RequestParam(value 
= "endDate", required = false) String endDate,
-                                                          @RequestParam(value 
= "projectCode", required = false, defaultValue = "0") long projectCode) {
-
-        TaskCountDto taskCountDto =
-                
dataAnalysisService.countProcessInstanceStateByProject(loginUser, projectCode, 
startDate, endDate);
-        return Result.success(taskCountDto);
+    public Result<WorkflowInstanceCountVo> 
getWorkflowInstanceStateCount(@Parameter(hidden = true) @RequestAttribute(value 
= Constants.SESSION_USER) User loginUser,
+                                                                         
@RequestParam(value = "startDate", required = false) String startDate,
+                                                                         
@RequestParam(value = "endDate", required = false) String endDate,
+                                                                         
@RequestParam(value = "projectCode", required = false) Long projectCode) {
+        if (projectCode == null) {
+            return 
Result.success(dataAnalysisService.getAllWorkflowInstanceStateCount(loginUser, 
startDate, endDate));
+        }
+        return Result.success(
+                
dataAnalysisService.getWorkflowInstanceStateCountByProject(loginUser, 
projectCode, startDate, endDate));
     }
 
-    /**
-     * statistics the process definition quantities of certain person
-     *
-     * @param loginUser login user
-     * @param projectCode project code
-     * @return definition count in project code
-     */
     @Operation(summary = "countDefinitionByUser", description = 
"COUNT_PROCESS_DEFINITION_BY_USER_NOTES")
     @Parameters({
             @Parameter(name = "projectCode", description = "PROJECT_CODE", 
schema = @Schema(implementation = long.class, example = "100"))
     })
     @GetMapping(value = "/define-user-count")
     @ResponseStatus(HttpStatus.OK)
     @ApiException(COUNT_PROCESS_DEFINITION_USER_ERROR)
-    public Result<DefineUserDto> countDefinitionByUser(@Parameter(hidden = 
true) @RequestAttribute(value = Constants.SESSION_USER) User loginUser,
-                                                       @RequestParam(value = 
"projectCode", required = false, defaultValue = "0") long projectCode) {
-
-        DefineUserDto defineUserDto = 
dataAnalysisService.countDefinitionByUser(loginUser, projectCode);
-        return Result.success(defineUserDto);
+    public Result<WorkflowDefinitionCountVo> 
countDefinitionByUser(@Parameter(hidden = true) @RequestAttribute(value = 
Constants.SESSION_USER) User loginUser,
+                                                                   
@RequestParam(value = "projectCode", required = false) Long projectCode) {
+        if (projectCode == null || projectCode == 0) {

Review Comment:
   Why this line needs check `projectCode == 0`, looks like logic is simily 
above



##########
dolphinscheduler-dao/src/main/resources/org/apache/dolphinscheduler/dao/mapper/ProcessInstanceMapper.xml:
##########
@@ -170,23 +170,25 @@
         where worker_group = #{originWorkerGroupName}
     </update>
 
-    <select id="countInstanceStateByProjectCodes"
-            
resultType="org.apache.dolphinscheduler.dao.entity.ExecuteStatusCount">
-        select t.state, count(0) as count
-        from t_ds_process_instance t
-        join t_ds_process_definition d on d.code=t.process_definition_code
-        where t.is_sub_process = 0
+    <select id="countWorkflowInstanceStateByProjectCodes" 
resultType="org.apache.dolphinscheduler.dao.model.WorkflowInstanceStatusCountDto">
+        select state, count(0) as count
+        from t_ds_process_instance
+        where is_sub_process = 0
         <if test="startTime != null and endTime != null">

Review Comment:
   ```suggestion
           <if test="startTime != null>
   ```



-- 
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: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to