refactor(任务中心): 优化任务默认按创建时间排序&测试计划接口count查询慢sql

This commit is contained in:
WangXu10 2024-10-23 14:15:24 +08:00 committed by Craftsman
parent 21e12756d9
commit 8e9d4d946b
3 changed files with 8 additions and 4 deletions

View File

@ -109,5 +109,9 @@ CREATE TABLE IF NOT EXISTS api_report_relate_task(
DEFAULT CHARSET = utf8mb4 DEFAULT CHARSET = utf8mb4
COLLATE = utf8mb4_general_ci COMMENT = '报告与任务关联表'; COLLATE = utf8mb4_general_ci COMMENT = '报告与任务关联表';
CREATE INDEX idx_deleted ON api_test_case(`deleted`);
-- set innodb lock wait timeout to default -- set innodb lock wait timeout to default
SET SESSION innodb_lock_wait_timeout = DEFAULT; SET SESSION innodb_lock_wait_timeout = DEFAULT;

View File

@ -215,13 +215,13 @@
api_test_case.deleted = #{deleted} api_test_case.deleted = #{deleted}
<include refid="io.metersphere.api.mapper.ExtApiDefinitionMapper.queryWhereCondition"/> <include refid="io.metersphere.api.mapper.ExtApiDefinitionMapper.queryWhereCondition"/>
<if test="request.testPlanId != null and request.testPlanId != ''"> <if test="request.testPlanId != null and request.testPlanId != ''">
and exists ( and api_test_case.id in (
select id select id
from api_test_case c from api_test_case c
where c.api_definition_id = api_definition.id and c.deleted = false where c.api_definition_id = api_definition.id and c.deleted = false
<if test="!isRepeat"> <if test="!isRepeat">
and not exists ( and c.id not in (
select id select t.api_case_id
from test_plan_api_case t from test_plan_api_case t
where t.api_case_id = c.id where t.api_case_id = c.id
and t.test_plan_id = #{request.testPlanId} and t.test_plan_id = #{request.testPlanId}

View File

@ -138,7 +138,7 @@ public class BaseTaskHubService {
*/ */
public Pager<List<TaskHubDTO>> getTaskList(BasePageRequest request, String orgId, String projectId) { public Pager<List<TaskHubDTO>> getTaskList(BasePageRequest request, String orgId, String projectId) {
Page<Object> page = PageMethod.startPage(request.getCurrent(), request.getPageSize(), Page<Object> page = PageMethod.startPage(request.getCurrent(), request.getPageSize(),
StringUtils.isNotBlank(request.getSortString()) ? request.getSortString() : "start_time desc"); StringUtils.isNotBlank(request.getSortString()) ? request.getSortString() : "create_time desc");
return PageUtils.setPageInfo(page, getPage(request, orgId, projectId)); return PageUtils.setPageInfo(page, getPage(request, orgId, projectId));
} }