refactor(测试计划): 测试计划报告用例列表返回请求总耗时

This commit is contained in:
WangXu10 2024-12-09 17:11:37 +08:00 committed by Craftsman
parent 01bd11b858
commit 3f476afcdc
4 changed files with 12 additions and 3 deletions

View File

@ -37,4 +37,8 @@ public class ReportDetailCasePageDTO {
private String collectionId;
@Schema(description = "测试点名称")
private String collectionName;
@Schema(description = "耗时ms")
private Long requestDuration;
@Schema(description = "耗时s")
private Double requestTime;
}

View File

@ -38,9 +38,10 @@
<!-- ID、用例名称、所属模块、用例等级、执行人、执行结果、缺陷数、接口报告ID -->
select tprac.api_case_id as id, tprac.api_case_num as num, tprac.api_case_name as name, tprac.test_plan_name as planName, tprac.test_plan_collection_id collectionId, tpc.name collectionName,
tprac.api_case_module as moduleName, tprac.api_case_priority as priority, tprac.api_case_execute_report_id reportId, ifnull(tprac.api_case_bug_count, 0) as bugCount,
ifnull(tprac.api_case_execute_result, 'PENDING') as executeResult, tprac.api_case_execute_user as executeUser, atc.project_id projectId
ifnull(tprac.api_case_execute_result, 'PENDING') as executeResult, tprac.api_case_execute_user as executeUser, atc.project_id projectId, ar.request_duration as requestDuration
from test_plan_report_api_case tprac left join api_test_case atc on tprac.api_case_id = atc.id
left join test_plan_collection tpc on tprac.test_plan_collection_id = tpc.id
left join api_report ar on tprac.api_case_execute_report_id = ar.id
where tprac.test_plan_report_id in
<foreach collection="request.detailReportIds" item="id" open="(" close=")" separator=",">
#{id}

View File

@ -37,9 +37,10 @@
<!-- ID、用例名称、所属模块、用例等级、执行人、执行结果、缺陷数、报告ID -->
select distinct tpras.api_scenario_id as id, tpras.api_scenario_num as num, tpras.api_scenario_name as name, tpras.test_plan_name as planName, tpras.test_plan_collection_id collectionId, tpc.name collectionName,
tpras.api_scenario_module as moduleName, tpras.api_scenario_priority as priority, tpras.api_scenario_execute_report_id reportId, ifnull(tpras.api_scenario_bug_count, 0) as bugCount,
ifnull(tpras.api_scenario_execute_result, 'PENDING') as executeResult, tpras.api_scenario_execute_user as executeUser, aso.project_id projectId
ifnull(tpras.api_scenario_execute_result, 'PENDING') as executeResult, tpras.api_scenario_execute_user as executeUser, aso.project_id projectId, asr.request_duration as requestDuration
from test_plan_report_api_scenario tpras left join api_scenario aso on tpras.api_scenario_id = aso.id
left join test_plan_collection tpc on tpras.test_plan_collection_id = tpc.id
left join api_scenario_report asr on tpras.api_scenario_execute_report_id = asr.id
where tpras.test_plan_report_id in
<foreach collection="request.detailReportIds" item="id" open="(" close=")" separator=",">
#{id}

View File

@ -941,7 +941,10 @@ public class TestPlanReportService {
List<String> distinctUserIds = detailCases.stream().map(ReportDetailCasePageDTO::getExecuteUser).distinct().collect(Collectors.toList());
distinctUserIds.removeIf(StringUtils::isEmpty);
Map<String, String> userMap = getUserMap(distinctUserIds);
detailCases.forEach(detailCase -> detailCase.setExecuteUser(userMap.getOrDefault(detailCase.getExecuteUser(), detailCase.getExecuteUser())));
detailCases.forEach(detailCase -> {
detailCase.setExecuteUser(userMap.getOrDefault(detailCase.getExecuteUser(), detailCase.getExecuteUser()));
detailCase.setRequestTime(detailCase.getRequestDuration() == null ? 0 : detailCase.getRequestDuration() / 1000.0);
});
return detailCases;
}