fix(测试跟踪): 修复实时报告查询接口用例资源池的方式

--bug=1024555 --user=宋天阳 【测试跟踪】计划中只有接口用例-执行计划选择k8s资源池-查看临时报告-资源池仍显示LOCAL
https://www.tapd.cn/55049933/s/1353978
This commit is contained in:
song-tianyang 2023-03-21 19:00:06 +08:00 committed by 建国
parent 71f6913036
commit 77d176bd31
3 changed files with 11 additions and 12 deletions

View File

@ -63,6 +63,6 @@ public interface ExtTestPlanApiCaseMapper {
List<TestPlanApiCase> selectByRefIds(@Param("ids") List<String> ids);
List<String> selectResourcePoolIdByTestPlanApiIds(@Param("ids") List<String> resourceIds);
List<String> selectResourcePoolIdByReportIds(@Param("ids") List<String> resourceIds);
}

View File

@ -556,15 +556,10 @@
ORDER BY t.order DESC
</select>
<select id="selectResourcePoolIdByTestPlanApiIds" resultType="java.lang.String">
SELECT DISTINCT actuator FROM api_definition_exec_result execResult
INNER JOIN (
SELECT id, resource_id, max( create_time + 0 ) AS create_time
FROM api_definition_exec_result WHERE resource_id IN
<foreach collection="ids" item="id" separator="," open="(" close=")">
#{id}
</foreach>
) t ON execResult.id = t.id
<select id="selectResourcePoolIdByReportIds" resultType="java.lang.String">
SELECT DISTINCT actuator FROM api_definition_exec_result WHERE id IN
<foreach collection="ids" item="id" separator="," open="(" close=")">
#{id}
</foreach>
</select>
</mapper>

View File

@ -526,11 +526,13 @@ public class TestPlanApiCaseService {
Map<String, List<String>> result = new LinkedHashMap<>();
List<String> resourcePoolIds = new ArrayList<>();
if (!CollectionUtils.isEmpty(resourceIds)) {
List<String> reportIdList = new ArrayList<>();
List<ApiDefinitionExecResultWithBLOBs> execResults = apiDefinitionExecResultService.selectByResourceIdsAndMaxCreateTime(resourceIds);
Map<String, List<String>> projectConfigMap = new HashMap<>();
execResults.forEach(item -> {
String envConf = item.getEnvConfig();
String projectId = item.getProjectId();
reportIdList.add(item.getId());
if (projectConfigMap.containsKey(projectId)) {
projectConfigMap.get(projectId).add(envConf);
} else {
@ -540,7 +542,9 @@ public class TestPlanApiCaseService {
}
});
result = apiDefinitionService.getProjectEnvNameByEnvConfig(projectConfigMap);
resourcePoolIds = extTestPlanApiCaseMapper.selectResourcePoolIdByTestPlanApiIds(resourceIds);
if (CollectionUtils.isNotEmpty(reportIdList)) {
resourcePoolIds = extTestPlanApiCaseMapper.selectResourcePoolIdByReportIds(reportIdList);
}
}
AutomationsRunInfoDTO returnDTO = new AutomationsRunInfoDTO();
returnDTO.setProjectEnvMap(result);