fix(接口测试): 优化测试报告的查询效率

优化测试报告的查询效率
This commit is contained in:
song-tianyang 2022-03-03 16:36:28 +08:00 committed by CountryBuilder
parent 2c240ac576
commit 5190c35b26
4 changed files with 28 additions and 0 deletions

View File

@ -36,6 +36,7 @@ public class APIScenarioReportController {
@PostMapping("/list/{goPage}/{pageSize}") @PostMapping("/list/{goPage}/{pageSize}")
public Pager<List<APIScenarioReportResult>> list(@PathVariable int goPage, @PathVariable int pageSize, @RequestBody QueryAPIReportRequest request) { public Pager<List<APIScenarioReportResult>> list(@PathVariable int goPage, @PathVariable int pageSize, @RequestBody QueryAPIReportRequest request) {
Page<Object> page = PageHelper.startPage(goPage, pageSize, true); Page<Object> page = PageHelper.startPage(goPage, pageSize, true);
request.setLimit("LIMIT " + (goPage - 1) * pageSize + "," + pageSize * 50);
return PageUtils.setPageInfo(page, apiReportService.list(request)); return PageUtils.setPageInfo(page, apiReportService.list(request));
} }

View File

@ -20,4 +20,6 @@ public class QueryAPIReportRequest {
private List<OrderRequest> orders; private List<OrderRequest> orders;
private Map<String, List<String>> filters; private Map<String, List<String>> filters;
private Map<String, Object> combine; private Map<String, Object> combine;
private String limit;
} }

View File

@ -138,6 +138,7 @@
</sql> </sql>
<select id="list" resultMap="BaseResultMap"> <select id="list" resultMap="BaseResultMap">
select * from (
select * from ( select * from (
SELECT s_r.name AS test_name, SELECT s_r.name AS test_name,
s_r.end_time, s_r.end_time,
@ -196,8 +197,19 @@
</foreach> </foreach>
</if> </if>
AND s_r.execute_type = 'Saved' AND s_r.execute_type = 'Saved'
<if test="request.orders != null and request.orders.size() > 0">
order by
<foreach collection="request.orders" separator="," item="order">
${order.name} ${order.type}
</foreach>
</if>
<if test="request.limit != null">
${request.limit}
</if>
</where> </where>
) apiScenarioReport
union union
select * from (
select a_r.name as test_name, select a_r.name as test_name,
a_r.end_time, a_r.end_time,
a_r.user_id, a_r.user_id,
@ -254,6 +266,16 @@
</if> </if>
</foreach> </foreach>
</if> </if>
<if test="request.orders != null and request.orders.size() > 0">
order by
<foreach collection="request.orders" separator="," item="order">
${order.name} ${order.type}
</foreach>
</if>
<if test="request.limit != null">
${request.limit}
</if>
) apiDefinitionReport
) r ) r
<if test="request.orders != null and request.orders.size() > 0"> <if test="request.orders != null and request.orders.size() > 0">
order by order by

View File

@ -0,0 +1,3 @@
ALTER TABLE `api_definition_exec_result` ADD INDEX projectIdIndex ( `project_id` );
ALTER TABLE `api_scenario_report` ADD INDEX projectIdIndex ( `project_id` );
ALTER TABLE `api_scenario_report` ADD INDEX projectIdexectypeIndex ( `project_id`,`execute_type` );