diff --git a/backend/src/main/java/io/metersphere/api/dto/datacount/response/ApiDataCountDTO.java b/backend/src/main/java/io/metersphere/api/dto/datacount/response/ApiDataCountDTO.java index 4f9d9e16d6..1ed49369c7 100644 --- a/backend/src/main/java/io/metersphere/api/dto/datacount/response/ApiDataCountDTO.java +++ b/backend/src/main/java/io/metersphere/api/dto/datacount/response/ApiDataCountDTO.java @@ -188,11 +188,11 @@ public class ApiDataCountDTO { for (ApiDataCountResult countResult : allExecuteResult) { if("Success".equals(countResult.getGroupField())){ this.successCount+= countResult.getCountNumber(); - }else if("Error".equals(countResult.getGroupField())){ + this.executedCount+= countResult.getCountNumber(); + }else if("Error".equals(countResult.getGroupField())||"Fail".equals(countResult.getGroupField())){ this.failedCount+= countResult.getCountNumber(); + this.executedCount+= countResult.getCountNumber(); } - - this.executedCount+= countResult.getCountNumber(); } } } 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 237de40e9f..1d5cb3e351 100644 --- a/backend/src/main/java/io/metersphere/api/jmeter/APIBackendListenerClient.java +++ b/backend/src/main/java/io/metersphere/api/jmeter/APIBackendListenerClient.java @@ -179,28 +179,31 @@ public class APIBackendListenerClient extends AbstractBackendListenerClient impl testResult.setTestId(testId); ApiScenarioReport scenarioReport = apiScenarioReportService.complete(testResult, this.runMode); - report = new ApiTestReport(); report.setStatus(scenarioReport.getStatus()); report.setId(scenarioReport.getId()); report.setTriggerMode(scenarioReport.getTriggerMode()); report.setName(scenarioReport.getName()); - SystemParameterService systemParameterService = CommonBeanFactory.getBean(SystemParameterService.class); assert systemParameterService != null; BaseSystemConfigDTO baseSystemConfigDTO = systemParameterService.getBaseInfo(); reportUrl = baseSystemConfigDTO.getUrl() + "/#/api/automation/report"; - - String scenaName = scenarioReport.getName(); - if(scenaName==null){ + String scenaName = scenarioReport.getName(); + if (scenaName == null) { scenaName = ""; - }else { - scenaName = scenaName.split("-")[0]; + } else { + String[] sceneNameArr = scenaName.split("-"); + if (sceneNameArr.length >= 4) { + String endStr = "-" + sceneNameArr[sceneNameArr.length - 3] + "-" + sceneNameArr[sceneNameArr.length - 2] + "-" + sceneNameArr[sceneNameArr.length - 1]; + scenaName = scenaName.split(endStr)[0]; + } else { + scenaName = scenaName.split("-")[0]; + } } - String scenarioID = apiScenarioReportService.getApiScenarioId(scenaName,scenarioReport.getProjectId()); + String scenarioID = apiScenarioReportService.getApiScenarioId(scenaName, scenarioReport.getProjectId()); testResult.setTestId(scenarioID); } else { apiTestService.changeStatus(testId, APITestStatus.Completed); @@ -224,14 +227,14 @@ public class APIBackendListenerClient extends AbstractBackendListenerClient impl } } try { - sendTask(report,reportUrl, testResult); + sendTask(report, reportUrl, testResult); } catch (Exception e) { LogUtil.error(e.getMessage(), e); } } - private static void sendTask(ApiTestReport report,String reportUrl, TestResult testResult) { + private static void sendTask(ApiTestReport report, String reportUrl, TestResult testResult) { SystemParameterService systemParameterService = CommonBeanFactory.getBean(SystemParameterService.class); NoticeSendService noticeSendService = CommonBeanFactory.getBean(NoticeSendService.class); assert systemParameterService != null; @@ -239,7 +242,7 @@ public class APIBackendListenerClient extends AbstractBackendListenerClient impl BaseSystemConfigDTO baseSystemConfigDTO = systemParameterService.getBaseInfo(); String url = reportUrl; - if(StringUtils.isEmpty(url)){ + if (StringUtils.isEmpty(url)) { url = baseSystemConfigDTO.getUrl() + "/#/api/report/view/" + report.getId(); } String successContext = ""; 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 6d66b45840..a9a3e67c11 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 @@ -53,7 +53,7 @@ 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 reportDetail.content like concat('%"', scene.`name`,'"%') + INNER JOIN api_scenario scene ON report.scenario_id = scene.id LEFT JOIN ( SELECT 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 7eeac83c3e..5ad0ad5a92 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 @@ -179,8 +179,8 @@ SELECT count(acr.report_id) AS countNumber FROM api_scenario_report_detail acr INNER JOIN api_scenario_report ar ON ar.id = acr.report_id INNER JOIN ( - SELECT acitem.`name` FROM api_scenario acitem INNER JOIN `schedule` sc ON acitem.id = sc.resource_id - ) ac on acr.content like CONCAT('%"', ac.`name`,'"%') + SELECT acitem.`name`,acitem.id FROM api_scenario acitem INNER JOIN `schedule` sc ON acitem.id = sc.resource_id + ) ac on ar.scenario_id = ac.id WHERE acr.project_id = #{projectId} AND ar.create_time BETWEEN #{firstDayTimestamp} AND #{lastDayTimestamp} @@ -189,8 +189,8 @@ FROM api_scenario_report_detail acr INNER JOIN api_scenario_report ar ON ar.id = acr.report_id INNER JOIN ( - SELECT acitem.`name` FROM api_scenario acitem INNER JOIN `schedule` sc ON acitem.id = sc.resource_id - ) ac on acr.content like CONCAT('%"', ac.`name`,'"%') + SELECT acitem.`name`,acitem.id FROM api_scenario acitem INNER JOIN `schedule` sc ON acitem.id = sc.resource_id + ) ac on ar.scenario_id = ac.id WHERE acr.project_id = #{projectId} \ No newline at end of file diff --git a/backend/src/main/java/io/metersphere/base/mapper/ext/ExtScheduleMapper.xml b/backend/src/main/java/io/metersphere/base/mapper/ext/ExtScheduleMapper.xml index 77d343086c..9134566d53 100644 --- a/backend/src/main/java/io/metersphere/base/mapper/ext/ExtScheduleMapper.xml +++ b/backend/src/main/java/io/metersphere/base/mapper/ext/ExtScheduleMapper.xml @@ -38,17 +38,17 @@ @@ -61,8 +61,8 @@ UNION SELECT apiScene.`name` AS scenario,sch.id AS taskID,sch.`value` AS rule,sch.`enable` AS `taskStatus`,u.`name` AS creator,sch.update_time AS updateTime FROM api_scenario apiScene - INNER JOIN `schedule` sch ON apiScene.id = sch.resource_id - INNER JOIN `user` u ON u.id = sch.user_id + INNER JOIN `schedule` sch ON apiScene.id = sch.resource_id + INNER JOIN `user` u ON u.id = sch.user_id WHERE sch.`enable` = true AND apiScene.project_id = #{0,jdbcType=VARCHAR} \ No newline at end of file