From bfd6db75a373be57ac0934922e703d5b840487c4 Mon Sep 17 00:00:00 2001 From: song-tianyang Date: Mon, 25 Jul 2022 15:43:46 +0800 Subject: [PATCH] =?UTF-8?q?fix(=E6=B5=8B=E8=AF=95=E8=B7=9F=E8=B8=AA):=20?= =?UTF-8?q?=E4=BF=AE=E5=A4=8D=E5=A4=B1=E8=B4=A5=E7=94=A8=E4=BE=8Btop10?= =?UTF-8?q?=E5=9C=BA=E6=99=AF=E7=94=A8=E4=BE=8B=E5=9C=A8=E4=B8=8D=E5=90=8C?= =?UTF-8?q?=E6=B5=8B=E8=AF=95=E8=AE=A1=E5=88=92=E5=86=85=E6=97=B6=E6=B2=A1?= =?UTF-8?q?=E6=9C=89=E5=88=86=E5=BC=80=E7=BB=9F=E8=AE=A1=E7=9A=84=E9=97=AE?= =?UTF-8?q?=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --bug=1015301 --user=宋天阳 【测试跟踪】首页-测试计划失败用例top10,一个场景被多个测试计划关联,失败次数应该分别显示 https://www.tapd.cn/55049933/s/1210153 --- .../api/service/ApiScenarioReportService.java | 3 - .../api/service/TestResultService.java | 6 +- .../ext/ExtApiDefinitionExecResultMapper.java | 2 - .../ext/ExtApiDefinitionExecResultMapper.xml | 84 ++----------------- .../mapper/ext/ExtApiScenarioReportMapper.xml | 23 +++-- 5 files changed, 30 insertions(+), 88 deletions(-) diff --git a/backend/src/main/java/io/metersphere/api/service/ApiScenarioReportService.java b/backend/src/main/java/io/metersphere/api/service/ApiScenarioReportService.java index 74db2ff2d2..a57cb80869 100644 --- a/backend/src/main/java/io/metersphere/api/service/ApiScenarioReportService.java +++ b/backend/src/main/java/io/metersphere/api/service/ApiScenarioReportService.java @@ -308,9 +308,6 @@ public class ApiScenarioReportService { testPlanApiScenario.setUpdateTime(System.currentTimeMillis()); testPlanApiScenarioMapper.updateByPrimaryKeySelective(testPlanApiScenario); - //增加场景的运行记录 - scenarioExecutionInfoService.insertExecutionInfo(testPlanApiScenario.getId(), status, report.getTriggerMode()); - // 更新场景状态 ApiScenario scenario = apiScenarioMapper.selectByPrimaryKey(testPlanApiScenario.getApiScenarioId()); if (scenario != null) { diff --git a/backend/src/main/java/io/metersphere/api/service/TestResultService.java b/backend/src/main/java/io/metersphere/api/service/TestResultService.java index 59f0761e0b..91b1bae971 100644 --- a/backend/src/main/java/io/metersphere/api/service/TestResultService.java +++ b/backend/src/main/java/io/metersphere/api/service/TestResultService.java @@ -187,7 +187,11 @@ public class TestResultService { } else { ApiScenarioWithBLOBs apiScenario = apiScenarioMapper.selectByPrimaryKey(scenarioReport.getScenarioId()); if (apiScenario != null) { - scenarioExecutionInfoService.insertExecutionInfo(scenarioReport.getScenarioId(), scenarioReport.getStatus(), scenarioReport.getTriggerMode()); + if (StringUtils.equalsAnyIgnoreCase(dto.getRunMode(), ApiRunMode.SCENARIO_PLAN.name(), ApiRunMode.SCHEDULE_SCENARIO_PLAN.name(), ApiRunMode.JENKINS_SCENARIO_PLAN.name())) { + scenarioExecutionInfoService.insertExecutionInfo(dto.getTestId(), scenarioReport.getStatus(), scenarioReport.getTriggerMode()); + } else { + scenarioExecutionInfoService.insertExecutionInfo(scenarioReport.getScenarioId(), scenarioReport.getStatus(), scenarioReport.getTriggerMode()); + } environment = apiScenarioReportService.getEnvironment(apiScenario); userName = apiAutomationService.getUser(apiScenario.getUserId()); principal = apiAutomationService.getUser(apiScenario.getPrincipal()); diff --git a/backend/src/main/java/io/metersphere/base/mapper/ext/ExtApiDefinitionExecResultMapper.java b/backend/src/main/java/io/metersphere/base/mapper/ext/ExtApiDefinitionExecResultMapper.java index 0ce1189e4f..c4b5bb215f 100644 --- a/backend/src/main/java/io/metersphere/base/mapper/ext/ExtApiDefinitionExecResultMapper.java +++ b/backend/src/main/java/io/metersphere/base/mapper/ext/ExtApiDefinitionExecResultMapper.java @@ -28,8 +28,6 @@ public interface ExtApiDefinitionExecResultMapper { long countByTestCaseIDInProject(String projectId); - List findFaliureCaseInfoByProjectIDAndExecuteTimeAndLimitNumber(@Param("projectId") String projectId, @Param("startTimestamp") long startTimestamp); - List findFaliureCaseInTestPlanByProjectIDAndExecuteTimeAndLimitNumber(@Param("projectId") String projectId, @Param("selectFunctionCase") boolean selectFunctionCase, @Param("startTimestamp") long startTimestamp); String selectExecResult(String resourceId); diff --git a/backend/src/main/java/io/metersphere/base/mapper/ext/ExtApiDefinitionExecResultMapper.xml b/backend/src/main/java/io/metersphere/base/mapper/ext/ExtApiDefinitionExecResultMapper.xml index aa14fe3cce..f1586a9881 100644 --- a/backend/src/main/java/io/metersphere/base/mapper/ext/ExtApiDefinitionExecResultMapper.xml +++ b/backend/src/main/java/io/metersphere/base/mapper/ext/ExtApiDefinitionExecResultMapper.xml @@ -110,8 +110,8 @@ testPlan.`name` AS testPlanName FROM test_plan_api_scenario testPlanScenario INNER JOIN test_plan testPlan ON testPlan.id = testPlanScenario.test_plan_id) apiScene - ON apiScene.api_scenario_id = executionInfo.source_id - INNER JOIN api_scenario scene ON scene.id = executionInfo.source_id + ON apiScene.id = executionInfo.source_id + INNER JOIN api_scenario scene ON scene.id = apiScene.api_scenario_id WHERE scene.project_id = #{projectId} AND scene.`status` != 'Trash' @@ -153,78 +153,6 @@ ) showTable ORDER BY showTable.failureTimes DESC - - update api_definition_exec_result set status="STOP" where status in ('Rerunning','Running','Waiting') + update api_definition_exec_result + set status="STOP" + where status in ('Rerunning', 'Running', 'Waiting') diff --git a/backend/src/main/java/io/metersphere/base/mapper/ext/ExtApiScenarioReportMapper.xml b/backend/src/main/java/io/metersphere/base/mapper/ext/ExtApiScenarioReportMapper.xml index 54c32b7b12..c13c108d46 100644 --- a/backend/src/main/java/io/metersphere/base/mapper/ext/ExtApiScenarioReportMapper.xml +++ b/backend/src/main/java/io/metersphere/base/mapper/ext/ExtApiScenarioReportMapper.xml @@ -352,11 +352,20 @@ SELECT count(id) AS countNumber FROM scenario_execution_info WHERE create_time BETWEEN #{firstDayTimestamp} AND #{lastDayTimestamp} - AND source_id in ( - SELECT id - FROM api_scenario - WHERE project_id = #{projectId} - ); + AND ( + source_id in ( + SELECT id + FROM api_scenario + WHERE project_id = #{projectId} + ) or + source_id in ( + select id + FROM test_plan_api_scenario + WHERE api_scenario_id in (SELECT id + FROM api_scenario + WHERE project_id = #{projectId}) + ) + ) - update api_scenario_report set status="STOP" where status in ('Rerunning','Running','Waiting') + update api_scenario_report + set status="STOP" + where status in ('Rerunning', 'Running', 'Waiting')