Skip to content

Commit

Permalink
perf: 提供步骤详情与步骤执行结果查询的APIGW接口 TencentBlueKing#2596
Browse files Browse the repository at this point in the history
步骤执行结果查询接口支持获取所有分组数据
  • Loading branch information
jsonwan committed Nov 27, 2023
1 parent 1ccbcbb commit 66c4143
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -143,6 +143,7 @@ public EsbResp<EsbStepInstanceStatusV3DTO> getStepInstanceStatus(String username
.logKeyword(keyword)
.searchIp(searchIp)
.maxAgentTasksForResultGroup(maxHostNumPerGroup)
.fetchAllGroupData(status == null)
.build();

StepExecutionDetailDTO executionResult = taskResultService.getStepExecutionResult(username, appId, query);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -89,6 +89,10 @@ public class StepExecutionResultQuery {
* 执行结果分组下返回的最大任务数
*/
private Integer maxAgentTasksForResultGroup;
/**
* 是否获取所有分组下的所有主机执行数据(默认为false,只获取第一个分组中的数据)
*/
private boolean fetchAllGroupData;
/**
* 排序字段
*/
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -322,10 +322,11 @@ private void setAgentTasksForAnyResultType(List<AgentTaskResultGroupDTO> resultG
StepInstanceBaseDTO stepInstance,
int executeCount,
Integer batch,
Integer maxAgentTasksForResultGroup) {
Integer maxAgentTasksForResultGroup,
boolean fetchAllGroupData) {
boolean isAgentTaskSet = false;
for (AgentTaskResultGroupDTO resultGroup : resultGroups) {
if (!isAgentTaskSet) {
if (!isAgentTaskSet || fetchAllGroupData) {
isAgentTaskSet = fillAgentTasksForResultGroup(resultGroup, stepInstance, executeCount,
batch, resultGroup.getStatus(), resultGroup.getTag(), maxAgentTasksForResultGroup);
} else {
Expand Down Expand Up @@ -533,7 +534,9 @@ private StepExecutionDetailDTO loadAllTasksFromDBAndBuildExecutionResultInMemory
filterAgentTasksByMatchIp(resultGroups, query.getMatchHostIds());
}

removeAgentTasksForNotSpecifiedResultGroup(resultGroups, query.getStatus(), query.getTag());
if (!query.isFetchAllGroupData()) {
removeAgentTasksForNotSpecifiedResultGroup(resultGroups, query.getStatus(), query.getTag());
}
watch.stop();


Expand Down Expand Up @@ -725,11 +728,11 @@ private StepExecutionDetailDTO filterAndSortExecutionResultInDB(StopWatch watch,
setAgentTasksForSpecifiedResultType(resultGroups, status, tag, tasks);
} else {
setAgentTasksForAnyResultType(resultGroups, stepInstance, queryExecuteCount,
query.getBatch(), query.getMaxAgentTasksForResultGroup());
query.getBatch(), query.getMaxAgentTasksForResultGroup(), query.isFetchAllGroupData());
}
} else {
setAgentTasksForAnyResultType(resultGroups, stepInstance, queryExecuteCount,
query.getBatch(), query.getMaxAgentTasksForResultGroup());
query.getBatch(), query.getMaxAgentTasksForResultGroup(), query.isFetchAllGroupData());
}
watch.stop();

Expand Down

0 comments on commit 66c4143

Please sign in to comment.