From 22ebbc532951742685ace37461790a87697a1bcb Mon Sep 17 00:00:00 2001 From: song-tianyang Date: Mon, 1 Aug 2022 10:50:44 +0800 Subject: [PATCH] =?UTF-8?q?style(=E6=8E=A5=E5=8F=A3=E6=B5=8B=E8=AF=95):=20?= =?UTF-8?q?=E4=BF=AE=E5=A4=8D=E6=8E=A5=E5=8F=A3=E6=B5=8B=E8=AF=95=E9=A6=96?= =?UTF-8?q?=E9=A1=B5=E7=94=A8=E4=BE=8B=E6=95=B0=E9=87=8F=E7=BB=9F=E8=AE=A1?= =?UTF-8?q?=E9=A1=B5=E7=AD=BE=E7=BB=9F=E8=AE=A1=E8=BE=83=E6=85=A2=E7=9A=84?= =?UTF-8?q?=E9=97=AE=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --bug=1015401 --user=宋天阳 【接口测试】首页,接口用例数量加载的比较慢 https://www.tapd.cn/55049933/s/1215951 --- .../api/controller/APITestController.java | 8 ----- .../ext/ExtApiDefinitionExecResultMapper.xml | 29 ++++++++++--------- 2 files changed, 16 insertions(+), 21 deletions(-) diff --git a/backend/src/main/java/io/metersphere/api/controller/APITestController.java b/backend/src/main/java/io/metersphere/api/controller/APITestController.java index 83a35bc70a..5263ffd6dc 100644 --- a/backend/src/main/java/io/metersphere/api/controller/APITestController.java +++ b/backend/src/main/java/io/metersphere/api/controller/APITestController.java @@ -204,35 +204,27 @@ public class APITestController { @GetMapping("/testCaseInfoCount/{projectId}") public ApiDataCountDTO testCaseInfoCount(@PathVariable String projectId) { ApiDataCountDTO apiCountResult = new ApiDataCountDTO(); - List countResultList = apiTestCaseService.countProtocolByProjectID(projectId); apiCountResult.countProtocal(countResultList); - long dateCountByCreateInThisWeek = apiTestCaseService.countByProjectIDAndCreateInThisWeek(projectId); apiCountResult.setThisWeekAddedCount(dateCountByCreateInThisWeek); - long executedInThisWeekCountNumber = apiDefinitionExecResultService.countByTestCaseIDInProjectAndExecutedInThisWeek(projectId); apiCountResult.setThisWeekExecutedCount(executedInThisWeekCountNumber); long executedCountNumber = apiDefinitionExecResultService.countByTestCaseIDInProject(projectId); apiCountResult.setExecutedCount(executedCountNumber); - //未覆盖 已覆盖: 统计当前接口下是否含有案例 List countResultByApiCoverageList = apiDefinitionService.countApiCoverageByProjectID(projectId); apiCountResult.countApiCoverage(countResultByApiCoverageList); long allCount = apiCountResult.getCoverageCount() + apiCountResult.getUncoverageCount(); - if (allCount != 0) { float coverageRageNumber = (float) apiCountResult.getCoverageCount() * 100 / allCount; DecimalFormat df = new DecimalFormat("0.0"); apiCountResult.setCoverageRage(df.format(coverageRageNumber) + "%"); } - - apiCountResult.setHttpCountStr("HTTP  

" + apiCountResult.getHttpApiDataCountNumber()); apiCountResult.setRpcCountStr("RPC  

" + apiCountResult.getRpcApiDataCountNumber()); apiCountResult.setTcpCountStr("TCP  

" + apiCountResult.getTcpApiDataCountNumber()); apiCountResult.setSqlCountStr("SQL  

" + apiCountResult.getSqlApiDataCountNumber()); - //计算用例的通过率 List apiCaseExecResultList = apiTestCaseService.selectExecuteResultByProjectId(projectId); long unexecuteCount = 0; 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 f1586a9881..b0967e56f9 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 @@ -26,17 +26,20 @@ @@ -47,13 +50,13 @@ SELECT testCase.id FROM api_test_case testCase WHERE testCase.project_id = #{projectId} - UNION - SELECT id - FROM test_plan_api_case - WHERE api_case_id IN (SELECT testCase.id - FROM api_test_case testCase - WHERE testCase.project_id = #{projectId}) ) + OR source_id IN (SELECT id + FROM test_plan_api_case + WHERE api_case_id IN ( + SELECT testCase.id + FROM api_test_case testCase + WHERE testCase.project_id = #{projectId}))