From 98b52d0c32ea46720e4ebdaf6625ac33c4d29e53 Mon Sep 17 00:00:00 2001 From: song-tianyang Date: Wed, 30 Aug 2023 16:59:44 +0800 Subject: [PATCH] =?UTF-8?q?perf(=E6=8E=A5=E5=8F=A3=E6=B5=8B=E8=AF=95):=20?= =?UTF-8?q?=E4=BC=98=E5=8C=96=E6=8E=A5=E5=8F=A3=E6=B5=8B=E8=AF=95=E9=A6=96?= =?UTF-8?q?=E9=A1=B5=E7=BB=9F=E8=AE=A1=EF=BC=8C=E9=83=A8=E5=88=86=E6=B6=89?= =?UTF-8?q?=E5=8F=8A=E5=88=B0=E8=AE=A1=E7=AE=97=E7=9A=84=E6=95=B0=E6=8D=AE?= =?UTF-8?q?=E5=8D=95=E5=BC=80=E6=8E=A5=E5=8F=A3=E5=A4=84=E7=90=86?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --bug=1028467 --user=宋天阳 【接口测试】github#26028,api-test模块,接口数量很多,8k+,页面接口查询响应时间很慢,页面需要十几秒才会加载出来 https://www.tapd.cn/55049933/s/1410126 --- .../mapper/ext/ExtApiDefinitionMapper.java | 2 +- .../mapper/ext/ExtApiDefinitionMapper.xml | 20 +-- .../base/mapper/ext/ExtApiTestCaseMapper.xml | 1 + .../controller/home/ApiHomeController.java | 132 +++++++++++------- .../definition/ApiDefinitionService.java | 17 +-- api-test/frontend/src/api/home.js | 16 ++- .../components/dashboard/ApiCaseDashboard.vue | 40 +++++- .../components/dashboard/ApiDashboard.vue | 52 ++++++- .../dashboard/ScenarioDashboard.vue | 39 +++++- 9 files changed, 228 insertions(+), 91 deletions(-) diff --git a/api-test/backend/src/main/java/io/metersphere/base/mapper/ext/ExtApiDefinitionMapper.java b/api-test/backend/src/main/java/io/metersphere/base/mapper/ext/ExtApiDefinitionMapper.java index 779c689ebc..d86b1ca336 100644 --- a/api-test/backend/src/main/java/io/metersphere/base/mapper/ext/ExtApiDefinitionMapper.java +++ b/api-test/backend/src/main/java/io/metersphere/base/mapper/ext/ExtApiDefinitionMapper.java @@ -22,7 +22,7 @@ public interface ExtApiDefinitionMapper { List selectByIds(@Param("ids") List ids, @Param("projectId") String projectId); - List selectByIdsAndStatusIsNotTrash(@Param("ids") List ids, @Param("projectId") String projectId); + List countByApiIdAndStatusIsNotTrash(@Param("ids") List ids, @Param("projectId") String projectId); int removeToGcByExample(ApiDefinitionExampleWithOperation example); diff --git a/api-test/backend/src/main/java/io/metersphere/base/mapper/ext/ExtApiDefinitionMapper.xml b/api-test/backend/src/main/java/io/metersphere/base/mapper/ext/ExtApiDefinitionMapper.xml index 99b952444e..a023ef07b1 100644 --- a/api-test/backend/src/main/java/io/metersphere/base/mapper/ext/ExtApiDefinitionMapper.xml +++ b/api-test/backend/src/main/java/io/metersphere/base/mapper/ext/ExtApiDefinitionMapper.xml @@ -117,15 +117,10 @@ - + SELECT t1.api_definition_id apiDefinitionId,count(t1.id) caseTotal FROM api_test_case t1 - LEFT JOIN api_definition_exec_result t2 ON t1.last_result_id=t2.id - WHERE t1.project_id = #{projectId} and (t1.status is null or t1.status != 'Trash') + WHERE (t1.status is null or t1.status != 'Trash') group by t1.api_definition_id having t1.api_definition_id in #{v} @@ -368,13 +363,12 @@ api_definition.description,api_definition.environment_id, api_definition.status, api_definition.user_id, api_definition.create_time, api_definition.update_time, project.name as - project_name, user.name as user_name,deleteUser.name AS delete_user,api_definition.delete_time, + project_name, user.name as user_name,api_definition.delete_user_id AS delete_user,api_definition.delete_time, api_definition.remark from (select * from api_definition where update_time >= #{startTimestamp} order by update_time desc)api_definition - left join project on api_definition.project_id = project.id - left join user on api_definition.user_id = user.id - left join user deleteUser on api_definition.delete_user_id = deleteUser.id + INNER join project on api_definition.project_id = project.id + INNER join user on api_definition.user_id = user.id order by @@ -1134,7 +1128,7 @@