From d7b99646597876009c20c8df86f509d14b2c35c6 Mon Sep 17 00:00:00 2001 From: song-tianyang Date: Thu, 23 Mar 2023 22:23:19 +0800 Subject: [PATCH] =?UTF-8?q?fix(=E6=B5=8B=E8=AF=95=E8=B7=9F=E8=B8=AA):=20?= =?UTF-8?q?=E6=B5=8B=E8=AF=95=E8=AE=A1=E5=88=92=E6=8A=A5=E5=91=8A=E9=92=88?= =?UTF-8?q?=E5=AF=B9=E6=B2=A1=E6=9C=89=E6=AD=A3=E5=B8=B8=E7=BB=93=E6=9D=9F?= =?UTF-8?q?=E7=9A=84=E6=97=A7=E6=95=B0=E6=8D=AE=E5=87=BA=E7=8E=B0=E8=A1=A8?= =?UTF-8?q?=E6=A0=BC=E4=B8=AD=E9=80=9A=E8=BF=87=E7=8E=87=E4=B8=BA=E7=A9=BA?= =?UTF-8?q?=E7=9A=84=E6=83=85=E5=86=B5=E8=BF=9B=E8=A1=8C=E4=BC=98=E5=8C=96?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --bug=1024852 --user=宋天阳 【测试跟踪】github#23094,测试跟踪里面的历史接口自动化测试报告成功率都变成0了 https://www.tapd.cn/55049933/s/1355334 --- .../plan/service/TestPlanReportService.java | 24 +++++++++++++++---- .../plan/service/TestPlanService.java | 14 +++++++---- 2 files changed, 30 insertions(+), 8 deletions(-) diff --git a/test-track/backend/src/main/java/io/metersphere/plan/service/TestPlanReportService.java b/test-track/backend/src/main/java/io/metersphere/plan/service/TestPlanReportService.java index 5ad87b486a..1b2085cd3c 100644 --- a/test-track/backend/src/main/java/io/metersphere/plan/service/TestPlanReportService.java +++ b/test-track/backend/src/main/java/io/metersphere/plan/service/TestPlanReportService.java @@ -139,13 +139,29 @@ public class TestPlanReportService { } catch (Exception e) { LogUtil.error("格式化查询请求参数出错!", e); } - return extTestPlanReportMapper.list(request); /* - 2.8之前的逻辑中,会检查有没有查到成功率,没查到的话重新计算。 - 现在想来,如果没查到就没查到。 报告结束的时候会统计成功率。 报告没结束,也没必要查询成功率。 - 在2.10之前这么处理没有问题时,2.10将去掉这段注释。 + 2.8之前的逻辑中,会检查有没有查到成功率,没查到的话重新计算。 2.8之后成功率的计算和测试数据统计绑定在一起。 + 以下是针对旧数据的处理:如果存在已完成但0成功率为0的报告,进行通过率的计算 */ + List testPlanReportDTOList = extTestPlanReportMapper.list(request); + for (TestPlanReportDTO testPlanReportDTO : testPlanReportDTOList) { + if (StringUtils.equalsAnyIgnoreCase( + testPlanReportDTO.getStatus(), + TestPlanReportStatus.FAILED.name(), + TestPlanReportStatus.COMPLETED.name(), + TestPlanReportStatus.SUCCESS.name()) + && (testPlanReportDTO.getPassRate() == null || testPlanReportDTO.getPassRate() == 0)) { + TestPlanReport testPlanReport = testPlanReportMapper.selectByPrimaryKey(testPlanReportDTO.getId()); + TestPlanReportContentWithBLOBs content = this.selectTestPlanReportContentByReportId(testPlanReportDTO.getId()); + TestPlanReportDataStruct testPlanReportCountData + = testPlanService.buildTestPlanReportStructByTestPlanReport(testPlanReport, content); + if (testPlanReportCountData != null) { + testPlanReportDTO.setPassRate(testPlanReportCountData.getPassRate()); + } + } + } + return testPlanReportDTOList; } } diff --git a/test-track/backend/src/main/java/io/metersphere/plan/service/TestPlanService.java b/test-track/backend/src/main/java/io/metersphere/plan/service/TestPlanService.java index c5a3df4550..d937d69f9e 100644 --- a/test-track/backend/src/main/java/io/metersphere/plan/service/TestPlanService.java +++ b/test-track/backend/src/main/java/io/metersphere/plan/service/TestPlanService.java @@ -156,10 +156,6 @@ public class TestPlanService { @Resource private ObjectMapper objectMapper; @Resource - private TestResourcePoolMapper testResourcePoolMapper; - @Resource - private TestPlanReportMapper testPlanReportMapper; - @Resource private ApiPoolDebugService apiPoolDebugService; public synchronized TestPlan addTestPlan(AddTestPlanRequest testPlan) { @@ -2112,4 +2108,14 @@ public class TestPlanService { return projectIds.stream().distinct().collect(Collectors.toList()); } + public TestPlanReportDataStruct buildTestPlanReportStructByTestPlanReport(TestPlanReport testPlanReport, TestPlanReportContentWithBLOBs testPlanReportContent) { + TestPlanWithBLOBs testPlanWithBLOBs = this.testPlanMapper.selectByPrimaryKey(testPlanReport.getTestPlanId()); + TestPlanReportDataStruct testPlanReportDataStruct = new TestPlanReportDataStruct(); + try { + testPlanReportDataStruct = this.buildTestPlanReportStruct(testPlanWithBLOBs, testPlanReport, testPlanReportContent); + } catch (Exception e) { + LoggerUtil.error("统计测试计划数据出错!", e); + } + return testPlanReportDataStruct; + } }