From e4e421f90a33d9ff31a425a091f3d9a8bed31b49 Mon Sep 17 00:00:00 2001 From: "song.tianyang" Date: Thu, 24 Dec 2020 14:51:59 +0800 Subject: [PATCH] =?UTF-8?q?fix:=20=E9=A6=96=E9=A1=B57=E5=A4=A9=E5=A4=B1?= =?UTF-8?q?=E8=B4=A5=E6=A1=88=E4=BE=8B=E7=BB=9F=E8=AE=A1=E4=B8=8D=E8=B6=B3?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 修复首页7天失败案例统计不足的问题、统计场景时统计了回收站内的数据都问题 --- .../api/jmeter/APIBackendListenerClient.java | 5 +---- .../api/service/ApiDefinitionExecResultService.java | 13 ++++++++++++- .../ext/ExtApiDefinitionExecResultMapper.java | 2 +- .../mapper/ext/ExtApiDefinitionExecResultMapper.xml | 11 +++++------ .../base/mapper/ext/ExtApiScenarioMapper.xml | 4 ++-- 5 files changed, 21 insertions(+), 14 deletions(-) diff --git a/backend/src/main/java/io/metersphere/api/jmeter/APIBackendListenerClient.java b/backend/src/main/java/io/metersphere/api/jmeter/APIBackendListenerClient.java index 66f71dc3f3..b4abea3e3d 100644 --- a/backend/src/main/java/io/metersphere/api/jmeter/APIBackendListenerClient.java +++ b/backend/src/main/java/io/metersphere/api/jmeter/APIBackendListenerClient.java @@ -204,13 +204,10 @@ public class APIBackendListenerClient extends AbstractBackendListenerClient impl } } ApiScenarioReport savedReport = apiScenarioReportService.get(testId); - String scenarioID = null; + String scenarioID = ""; if(savedReport!=null){ scenarioID = savedReport.getScenarioId(); } - if(scenarioID==null){ - scenarioID = apiScenarioReportService.getApiScenarioId(scenaName, scenarioReport.getProjectId()); - } testResult.setTestId(scenarioID); } else { diff --git a/backend/src/main/java/io/metersphere/api/service/ApiDefinitionExecResultService.java b/backend/src/main/java/io/metersphere/api/service/ApiDefinitionExecResultService.java index 8ec808f47c..3412cd9767 100644 --- a/backend/src/main/java/io/metersphere/api/service/ApiDefinitionExecResultService.java +++ b/backend/src/main/java/io/metersphere/api/service/ApiDefinitionExecResultService.java @@ -88,7 +88,18 @@ public class ApiDefinitionExecResultService { if (startTime == null) { return new ArrayList<>(0); } else { - return extApiDefinitionExecResultMapper.findFaliureCaseInfoByProjectIDAndExecuteTimeAndLimitNumber(projectId, startTime.getTime(), limitNumber); + Listlist = extApiDefinitionExecResultMapper.findFaliureCaseInfoByProjectIDAndExecuteTimeAndLimitNumber(projectId, startTime.getTime()); + + List returnList = new ArrayList<>(limitNumber); + for(int i = 0;i findFaliureCaseInfoByProjectIDAndExecuteTimeAndLimitNumber(@Param("projectId") String projectId, @Param("startTimestamp") long startTimestamp, @Param("limitNumber") int limitNumber); + List findFaliureCaseInfoByProjectIDAndExecuteTimeAndLimitNumber(@Param("projectId") String projectId, @Param("startTimestamp") long startTimestamp); } \ No newline at end of file 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 a9a3e67c11..0fa037c30c 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 @@ -52,9 +52,9 @@ UNION SELECT scene.`name` AS caseName,apiScene.testPlanName AS testPlan,count(report.id) AS failureTimes,'scenario' AS caseType FROM api_scenario_report report - INNER JOIN api_scenario_report_detail reportDetail ON report.id = reportDetail.report_id - INNER JOIN api_scenario scene ON report.scenario_id = scene.id - LEFT JOIN + INNER JOIN api_scenario_report_detail reportDetail ON report.id = reportDetail.report_id + INNER JOIN api_scenario scene ON report.scenario_id = scene.id + LEFT JOIN ( SELECT apiScene.api_scenario_id, @@ -65,10 +65,9 @@ GROUP BY apiScene.api_scenario_id )apiScene ON apiScene.api_scenario_id = scene.id WHERE report.project_id = #{projectId} - AND report.status = 'Error' AND report.create_time >= #{startTimestamp} - GROUP BY scene.id + AND ( report.STATUS = 'Error' OR report.STATUS = 'Fail' ) AND report.create_time >= #{startTimestamp} + GROUP BY scene.id ) showTable ORDER BY showTable.failureTimes DESC - limit #{limitNumber} \ No newline at end of file diff --git a/backend/src/main/java/io/metersphere/base/mapper/ext/ExtApiScenarioMapper.xml b/backend/src/main/java/io/metersphere/base/mapper/ext/ExtApiScenarioMapper.xml index c6d513502e..d4b91553d2 100644 --- a/backend/src/main/java/io/metersphere/base/mapper/ext/ExtApiScenarioMapper.xml +++ b/backend/src/main/java/io/metersphere/base/mapper/ext/ExtApiScenarioMapper.xml @@ -115,11 +115,11 @@