From fe254b8e92c3f2c9f1a88a42584dcc9c42c4ceaf Mon Sep 17 00:00:00 2001 From: song-tianyang Date: Fri, 18 Nov 2022 19:03:39 +0800 Subject: [PATCH] =?UTF-8?q?fix(=E6=8E=A5=E5=8F=A3=E6=B5=8B=E8=AF=95):=20?= =?UTF-8?q?=E4=BF=AE=E5=A4=8D=E6=B5=8B=E8=AF=95=E8=AE=A1=E5=88=92=E7=9A=84?= =?UTF-8?q?=E6=89=A7=E8=A1=8C=E6=95=B0=E6=8D=AE=E4=BC=9A=E8=A2=AB=E6=8E=A5?= =?UTF-8?q?=E5=8F=A3=E7=BB=9F=E8=AE=A1=E5=88=B0=E7=9A=84=E9=97=AE=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --bug=1019780 --user=宋天阳 【接口测试】首页 - 场景用例数量统计 - 执行次数统计,在测试计划中执行场景也会统计到接口模块 https://www.tapd.cn/55049933/s/1298691 --- .../base/mapper/ext/ExtApiScenarioReportMapper.java | 4 ++-- .../base/mapper/ext/ExtApiScenarioReportMapper.xml | 7 +++++++ .../metersphere/controller/home/ApiHomeController.java | 10 +++++----- .../scenario/ApiScenarioExecutionInfoService.java | 5 ++++- .../service/scenario/ApiScenarioReportService.java | 8 ++++---- .../service/scenario/ApiScenarioService.java | 4 ++-- 6 files changed, 24 insertions(+), 14 deletions(-) diff --git a/api-test/backend/src/main/java/io/metersphere/base/mapper/ext/ExtApiScenarioReportMapper.java b/api-test/backend/src/main/java/io/metersphere/base/mapper/ext/ExtApiScenarioReportMapper.java index 40eb41e7bb..dc3cd9676f 100644 --- a/api-test/backend/src/main/java/io/metersphere/base/mapper/ext/ExtApiScenarioReportMapper.java +++ b/api-test/backend/src/main/java/io/metersphere/base/mapper/ext/ExtApiScenarioReportMapper.java @@ -20,9 +20,9 @@ public interface ExtApiScenarioReportMapper { long countByProjectID(String projectId); - long countByProjectIdAndCreateInThisWeek(@Param("projectId") String projectId, @Param("version") String version, @Param("firstDayTimestamp") long firstDayTimestamp, @Param("lastDayTimestamp") long lastDayTimestamp); + long countByProjectIdAndCreateInThisWeek(@Param("projectId") String projectId, @Param("executeType") String executeType, @Param("version") String version, @Param("firstDayTimestamp") long firstDayTimestamp, @Param("lastDayTimestamp") long lastDayTimestamp); - long countByProjectIdAndCreateAndByScheduleInThisWeek(@Param("projectId") String projectId, @Param("version") String version, @Param("firstDayTimestamp") long firstDayTimestamp, @Param("lastDayTimestamp") long lastDayTimestamp); + long countByProjectIdAndCreateAndByScheduleInThisWeek(@Param("projectId") String projectId, @Param("executeType") String executeType, @Param("version") String version, @Param("firstDayTimestamp") long firstDayTimestamp, @Param("lastDayTimestamp") long lastDayTimestamp); List countByProjectIdGroupByExecuteResult(@Param("projectId") String projectId, @Param("version") String version); diff --git a/api-test/backend/src/main/java/io/metersphere/base/mapper/ext/ExtApiScenarioReportMapper.xml b/api-test/backend/src/main/java/io/metersphere/base/mapper/ext/ExtApiScenarioReportMapper.xml index 3c6d72c494..03cb4ade67 100644 --- a/api-test/backend/src/main/java/io/metersphere/base/mapper/ext/ExtApiScenarioReportMapper.xml +++ b/api-test/backend/src/main/java/io/metersphere/base/mapper/ext/ExtApiScenarioReportMapper.xml @@ -362,6 +362,10 @@ AND version = #{version} + + AND execute_type = #{executeType} + + diff --git a/api-test/backend/src/main/java/io/metersphere/controller/home/ApiHomeController.java b/api-test/backend/src/main/java/io/metersphere/controller/home/ApiHomeController.java index 86cad7c4a4..c935715924 100644 --- a/api-test/backend/src/main/java/io/metersphere/controller/home/ApiHomeController.java +++ b/api-test/backend/src/main/java/io/metersphere/controller/home/ApiHomeController.java @@ -144,10 +144,10 @@ public class ApiHomeController { //统计覆盖率 long dateCountByCreateInThisWeek = apiAutomationService.countScenarioByProjectIDAndCreatInThisWeek(projectId); apiCountResult.setCreatedInWeek(dateCountByCreateInThisWeek); - long executedInThisWeekCountNumber = apiScenarioReportService.countByProjectIdAndCreateInThisWeek(projectId, null); + long executedInThisWeekCountNumber = apiScenarioReportService.countByProjectIdAndCreateInThisWeek(projectId, ExecutionExecuteTypeEnum.BASIC.name(), null); apiCountResult.setExecutedTimesInWeek(executedInThisWeekCountNumber); //所有执行次数 - long executedTimes = apiAutomationService.countExecuteTimesByProjectID(projectId, null, null); + long executedTimes = apiAutomationService.countExecuteTimesByProjectID(projectId, null, ExecutionExecuteTypeEnum.BASIC.name(), null); apiCountResult.setExecutedTimes(executedTimes); //未执行、未通过、已通过 List countResultByRunResult = apiAutomationService.countRunResultByProjectID(projectId); @@ -188,9 +188,9 @@ public class ApiHomeController { apiCountResult.setTotal(allTaskCount); long taskCountInThisWeek = baseScheduleService.countTaskByProjectIdInThisWeek(projectId); apiCountResult.setCreatedInWeek(taskCountInThisWeek); - long executedInThisWeekCountNumber = apiScenarioReportService.countByProjectIdAndCreateAndByScheduleInThisWeek(projectId, null); + long executedInThisWeekCountNumber = apiScenarioReportService.countByProjectIdAndCreateAndByScheduleInThisWeek(projectId, ExecutionExecuteTypeEnum.BASIC.name(), null); apiCountResult.setExecutedTimesInWeek(executedInThisWeekCountNumber); - long executedTimes = apiAutomationService.countExecuteTimesByProjectID(projectId, ReportTriggerMode.SCHEDULE.name(), null); + long executedTimes = apiAutomationService.countExecuteTimesByProjectID(projectId, ReportTriggerMode.SCHEDULE.name(), ExecutionExecuteTypeEnum.BASIC.name(), null); apiCountResult.setExecutedTimes(executedTimes); //统计 失败 成功 以及总数 List allExecuteResult = apiScenarioReportService.countByProjectIdGroupByExecuteResult(projectId, null); @@ -233,7 +233,7 @@ public class ApiHomeController { @GetMapping("/failure/case/about/plan/{projectId}/{selectFunctionCase}/{limitNumber}/{goPage}/{pageSize}") public Pager> failureCaseAboutTestPlan(@PathVariable String projectId, @PathVariable boolean selectFunctionCase, - @PathVariable int limitNumber, @PathVariable int goPage, @PathVariable int pageSize) { + @PathVariable int limitNumber, @PathVariable int goPage, @PathVariable int pageSize) { Page page = PageHelper.startPage(goPage, pageSize, true); List selectDataList = apiDefinitionExecResultService.findFailureCaseInfoByProjectIDAndLimitNumberInSevenDays(projectId, selectFunctionCase, limitNumber); diff --git a/api-test/backend/src/main/java/io/metersphere/service/scenario/ApiScenarioExecutionInfoService.java b/api-test/backend/src/main/java/io/metersphere/service/scenario/ApiScenarioExecutionInfoService.java index d131c6b105..7712e8a189 100644 --- a/api-test/backend/src/main/java/io/metersphere/service/scenario/ApiScenarioExecutionInfoService.java +++ b/api-test/backend/src/main/java/io/metersphere/service/scenario/ApiScenarioExecutionInfoService.java @@ -91,7 +91,7 @@ public class ApiScenarioExecutionInfoService { scenarioExecutionInfoMapper.deleteByExample(example); } - public long countExecuteTimesByProjectID(String projectId, String triggerMode, String version) { + public long countExecuteTimesByProjectID(String projectId, String triggerMode, String executeType, String version) { ScenarioExecutionInfoExample example = new ScenarioExecutionInfoExample(); ScenarioExecutionInfoExample.Criteria criteria = example.createCriteria(); criteria.andProjectIdEqualTo(projectId); @@ -101,6 +101,9 @@ public class ApiScenarioExecutionInfoService { if (StringUtils.isNotEmpty(version)) { criteria.andVersionEqualTo(version); } + if (StringUtils.isNotEmpty(executeType)) { + criteria.andExecuteTypeEqualTo(executeType); + } return scenarioExecutionInfoMapper.countByExample(example); } diff --git a/api-test/backend/src/main/java/io/metersphere/service/scenario/ApiScenarioReportService.java b/api-test/backend/src/main/java/io/metersphere/service/scenario/ApiScenarioReportService.java index 80cfbc928c..def8a05a0d 100644 --- a/api-test/backend/src/main/java/io/metersphere/service/scenario/ApiScenarioReportService.java +++ b/api-test/backend/src/main/java/io/metersphere/service/scenario/ApiScenarioReportService.java @@ -718,7 +718,7 @@ public class ApiScenarioReportService { return ids; } - public long countByProjectIdAndCreateAndByScheduleInThisWeek(String projectId, String version) { + public long countByProjectIdAndCreateAndByScheduleInThisWeek(String projectId, String executeType, String version) { Map startAndEndDateInWeek = DateUtils.getWeedFirstTimeAndLastTime(new Date()); Date firstTime = startAndEndDateInWeek.get("firstTime"); @@ -727,11 +727,11 @@ public class ApiScenarioReportService { if (firstTime == null || lastTime == null) { return 0; } else { - return extApiScenarioReportMapper.countByProjectIdAndCreateAndByScheduleInThisWeek(projectId, version, firstTime.getTime(), lastTime.getTime()); + return extApiScenarioReportMapper.countByProjectIdAndCreateAndByScheduleInThisWeek(projectId, executeType, version, firstTime.getTime(), lastTime.getTime()); } } - public long countByProjectIdAndCreateInThisWeek(String projectId, String version) { + public long countByProjectIdAndCreateInThisWeek(String projectId, String executeType, String version) { Map startAndEndDateInWeek = DateUtils.getWeedFirstTimeAndLastTime(new Date()); Date firstTime = startAndEndDateInWeek.get("firstTime"); @@ -740,7 +740,7 @@ public class ApiScenarioReportService { if (firstTime == null || lastTime == null) { return 0; } else { - return extApiScenarioReportMapper.countByProjectIdAndCreateInThisWeek(projectId, version, firstTime.getTime(), lastTime.getTime()); + return extApiScenarioReportMapper.countByProjectIdAndCreateInThisWeek(projectId, executeType, version, firstTime.getTime(), lastTime.getTime()); } } diff --git a/api-test/backend/src/main/java/io/metersphere/service/scenario/ApiScenarioService.java b/api-test/backend/src/main/java/io/metersphere/service/scenario/ApiScenarioService.java index 773cce7f95..53879f4f9d 100644 --- a/api-test/backend/src/main/java/io/metersphere/service/scenario/ApiScenarioService.java +++ b/api-test/backend/src/main/java/io/metersphere/service/scenario/ApiScenarioService.java @@ -2010,8 +2010,8 @@ public class ApiScenarioService { return result; } - public long countExecuteTimesByProjectID(String projectId, String triggerMode, String version) { - return scenarioExecutionInfoService.countExecuteTimesByProjectID(projectId, triggerMode, version); + public long countExecuteTimesByProjectID(String projectId, String triggerMode, String executeType, String version) { + return scenarioExecutionInfoService.countExecuteTimesByProjectID(projectId, triggerMode, executeType, version); } /**