ruanwenjun commented on code in PR #15978:
URL:
https://github.com/apache/dolphinscheduler/pull/15978#discussion_r1597559003
##########
dolphinscheduler-api/src/main/java/org/apache/dolphinscheduler/api/controller/DataAnalysisController.java:
##########
@@ -148,4 +152,54 @@ public Result<Map<String, Integer>>
countQueueState(@Parameter(hidden = true) @R
Map<String, Integer> stringIntegerMap =
dataAnalysisService.countQueueState(loginUser);
return Result.success(stringIntegerMap);
}
+
+ /**
+ * command queue
+ *
+ * @param loginUser login user
+ * @return queue state count
+ */
+ @Operation(summary = "listQueueCommand", description =
"LIST_QUEUE_COMMAND_LIST_PAGING_NOTES")
+ @Parameters({
+ @Parameter(name = "searchVal", description = "SEARCH_VAL", schema
= @Schema(implementation = String.class)),
+ @Parameter(name = "pageNo", description = "PAGE_NO", required =
true, schema = @Schema(implementation = int.class, example = "1")),
+ @Parameter(name = "pageSize", description = "PAGE_SIZE", required
= true, schema = @Schema(implementation = int.class, example = "20"))
+ })
+ @GetMapping("/listCommand")
+ @ResponseStatus(HttpStatus.OK)
+ @ApiException(LIST_PAGING_ALERT_GROUP_ERROR)
+ public Result<PageInfo<Command>> listPaging(@Parameter(hidden = true)
@RequestAttribute(value = Constants.SESSION_USER) User loginUser,
+ @RequestParam(value =
"projectCode", required = false) Long projectCode,
+ @RequestParam("pageNo")
Integer pageNo,
+ @RequestParam("pageSize")
Integer pageSize) {
+ checkPageParams(pageNo, pageSize);
+ PageInfo<Command> commandPageInfo =
+ dataAnalysisService.listQueueCommand(loginUser, projectCode,
pageNo, pageSize);
Review Comment:
```suggestion
dataAnalysisService.listPendingCommands(loginUser,
projectCode, pageNo, pageSize);
```
##########
dolphinscheduler-dao/src/main/java/org/apache/dolphinscheduler/dao/mapper/CommandMapper.java:
##########
@@ -50,12 +52,15 @@ List<CommandCount> countCommandState(
*
* @return
*/
- List<Command> queryCommandPage(@Param("limit") int limit, @Param("offset")
int offset);
+ IPage<Command> queryCommandPage(Page<Command> page);
List<Command> queryCommandByIdSlot(@Param("currentSlotIndex") int
currentSlotIndex,
@Param("totalSlot") int totalSlot,
@Param("idStep") int idStep,
@Param("fetchNumber") int fetchNum);
void deleteByWorkflowInstanceIds(@Param("workflowInstanceIds")
List<Integer> workflowInstanceIds);
+
+ IPage<Command> queryCommandPageByIds(Page<Command> page,
@Param("definitionCodes") List<Long> definitionCodes,
+ @Param("projectCode") Long
projectCode);
Review Comment:
```suggestion
IPage<Command> queryCommandPageByIds(Page<Command> page,
@Param("workflowDefinitionCodes") List<Long> workflowDefinitionCodes);
```
Please remove the projectCode at this method, this param is never used?
And use more accurate naming for definitionCodes, since there exist
workflowDefinitionCodes and taskDefinitionCodes
##########
dolphinscheduler-dao/src/main/resources/org/apache/dolphinscheduler/dao/mapper/ErrorCommandMapper.xml:
##########
@@ -33,4 +33,26 @@
</if>
group by cmd.command_type
</select>
+
+ <select id="queryErrorCommandPage"
resultType="org.apache.dolphinscheduler.dao.entity.ErrorCommand">
+ select
+ *
+ from t_ds_error_command
+ where 1 = 1
Review Comment:
```suggestion
```
##########
dolphinscheduler-api/src/main/java/org/apache/dolphinscheduler/api/controller/DataAnalysisController.java:
##########
@@ -148,4 +152,54 @@ public Result<Map<String, Integer>>
countQueueState(@Parameter(hidden = true) @R
Map<String, Integer> stringIntegerMap =
dataAnalysisService.countQueueState(loginUser);
return Result.success(stringIntegerMap);
}
+
+ /**
+ * command queue
+ *
+ * @param loginUser login user
+ * @return queue state count
+ */
+ @Operation(summary = "listQueueCommand", description =
"LIST_QUEUE_COMMAND_LIST_PAGING_NOTES")
Review Comment:
```suggestion
@Operation(summary = "listPendingCommands", description =
"LIST_PENDING_COMMANDS")
```
##########
dolphinscheduler-dao/src/main/resources/org/apache/dolphinscheduler/dao/mapper/ProcessDefinitionMapper.xml:
##########
@@ -208,4 +208,17 @@
SELECT DISTINCT(id) as project_id
FROM t_ds_project
</select>
+
+ <select id="queryDefinitionCodeListByProjectCodes"
resultType="java.lang.Long">
+ select
+ code
+ from t_ds_process_definition
+ where 1=1
+ <if test="projectCodes != null and projectCodes.size() != 0">
+ and project_code in
+ <foreach collection="projectCodes" index="index" item="i" open="("
separator="," close=")">
+ #{i}
+ </foreach>
+ </if>
Review Comment:
If the `projectCodes` is a required param, we would better not check it is
empty here, if someone call this method but forget to set the projectCodes, it
will get all workflow definition codes.
```suggestion
where project_code in
<foreach collection="projectCodes" index="index" item="i"
open="(" separator="," close=")">
#{i}
</foreach>
```
##########
dolphinscheduler-dao/src/main/java/org/apache/dolphinscheduler/dao/mapper/ErrorCommandMapper.java:
##########
@@ -43,4 +45,10 @@ List<CommandCount> countCommandState(
@Param("startTime") Date startTime,
@Param("endTime") Date endTime,
@Param("projectCodes") List<Long>
projectCodes);
+
+ IPage<ErrorCommand> queryErrorCommandPage(Page<ErrorCommand> page);
+
+ IPage<ErrorCommand> queryErrorCommandPageByIds(Page<ErrorCommand> page,
+ @Param("definitionCodes")
List<Long> definitionCodes,
+ @Param("projectCode") Long
projectCode);
Review Comment:
```suggestion
IPage<ErrorCommand> queryErrorCommandPageByIds(Page<ErrorCommand> page,
@Param("workflowDefinitionCodes") List<Long> workflowDefinitionCodes);
```
Please remove the projectCode at this method, this param is never used?
And use more accurate naming for `definitionCodes`, since there exist
`workflowDefinitionCodes` and `taskDefinitionCodes`
##########
dolphinscheduler-dao/src/main/resources/org/apache/dolphinscheduler/dao/mapper/ErrorCommandMapper.xml:
##########
@@ -33,4 +33,26 @@
</if>
group by cmd.command_type
</select>
+
+ <select id="queryErrorCommandPage"
resultType="org.apache.dolphinscheduler.dao.entity.ErrorCommand">
+ select
+ *
+ from t_ds_error_command
+ where 1 = 1
+ order by process_instance_priority, id asc
+ </select>
+
+ <select id="queryErrorCommandPageByIds"
resultType="org.apache.dolphinscheduler.dao.entity.ErrorCommand">
+ select
+ *
+ from t_ds_error_command
+ where 1 = 1
+ <if test="definitionCodes != null and definitionCodes.size() > 0">
+ and process_definition_code in
+ <foreach item="id" index="index" collection="definitionCodes"
open="(" separator="," close=")">
+ #{id}
+ </foreach>
+ </if>
Review Comment:
```suggestion
where process_definition_code in
<foreach item="id" index="index" collection="definitionCodes"
open="(" separator="," close=")">
#{id}
</foreach>
```
If the workflowDefinitionCodes is a required param, we would better not
check it is empty here, if someone call this method but forget to set the
workflowDefinitionCodes, it will get all commands.
--
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]