refactor: 获取场景报告接口效率优化 (#9219)
Co-authored-by: chenjianxing <jianxing.chen@fit2cloud.com> Co-authored-by: jianxing <41557596+AgAngle@users.noreply.github.com>
This commit is contained in:
parent
1711505409
commit
deb9ad9670
|
@ -133,7 +133,16 @@ public class ApiScenarioReportService {
|
||||||
|
|
||||||
public List<APIScenarioReportResult> list(QueryAPIReportRequest request) {
|
public List<APIScenarioReportResult> list(QueryAPIReportRequest request) {
|
||||||
request.setOrders(ServiceUtils.getDefaultOrder(request.getOrders()));
|
request.setOrders(ServiceUtils.getDefaultOrder(request.getOrders()));
|
||||||
return extApiScenarioReportMapper.list(request);
|
List<APIScenarioReportResult> list = extApiScenarioReportMapper.list(request);
|
||||||
|
List<String> userIds = list.stream().map(APIScenarioReportResult::getUserId)
|
||||||
|
.collect(Collectors.toList());
|
||||||
|
Map<String, User> userMap = ServiceUtils.getUserMap(userIds);
|
||||||
|
list.forEach(item -> {
|
||||||
|
User user = userMap.get(item.getUserId());
|
||||||
|
if (user != null)
|
||||||
|
item.setUserName(user.getName());
|
||||||
|
});
|
||||||
|
return list;
|
||||||
}
|
}
|
||||||
|
|
||||||
public List<String> idList(QueryAPIReportRequest request) {
|
public List<String> idList(QueryAPIReportRequest request) {
|
||||||
|
|
|
@ -99,13 +99,10 @@
|
||||||
</sql>
|
</sql>
|
||||||
|
|
||||||
<select id="list" resultMap="BaseResultMap">
|
<select id="list" resultMap="BaseResultMap">
|
||||||
SELECT r.name AS test_name,r.end_time,
|
SELECT r.name AS test_name,r.end_time, r.user_id,
|
||||||
r.name, r.description, r.id, r.project_id, r.create_time, r.update_time, r.status, r.trigger_mode,IfNULL(s.name,r.scenario_name) as scenario_name,
|
r.name, r.description, r.id, r.project_id, r.create_time, r.update_time, r.status, r.trigger_mode,IfNULL(s.name,r.scenario_name) as scenario_name
|
||||||
project.name AS project_name, user.name AS user_name
|
|
||||||
FROM api_scenario_report r
|
FROM api_scenario_report r
|
||||||
LEFT JOIN api_scenario s on r.scenario_id = s.id
|
LEFT JOIN api_scenario s on r.scenario_id = s.id
|
||||||
LEFT JOIN project ON project.id = r.project_id
|
|
||||||
LEFT JOIN user ON user.id = r.user_id
|
|
||||||
<where>
|
<where>
|
||||||
<if test="request.combine != null">
|
<if test="request.combine != null">
|
||||||
<include refid="combine">
|
<include refid="combine">
|
||||||
|
@ -121,10 +118,7 @@
|
||||||
AND r.user_id = #{request.userId,jdbcType=VARCHAR}
|
AND r.user_id = #{request.userId,jdbcType=VARCHAR}
|
||||||
</if>
|
</if>
|
||||||
<if test="request.projectId != null">
|
<if test="request.projectId != null">
|
||||||
AND project.id = #{request.projectId}
|
AND r.project_id = #{request.projectId}
|
||||||
</if>
|
|
||||||
<if test="request.workspaceId != null">
|
|
||||||
AND project.workspace_id = #{request.workspaceId,jdbcType=VARCHAR}
|
|
||||||
</if>
|
</if>
|
||||||
<if test="request.filters != null and request.filters.size() > 0">
|
<if test="request.filters != null and request.filters.size() > 0">
|
||||||
<foreach collection="request.filters.entrySet()" index="key" item="values">
|
<foreach collection="request.filters.entrySet()" index="key" item="values">
|
||||||
|
|
|
@ -1,3 +1,6 @@
|
||||||
ALTER TABLE test_plan_report_content ADD plan_scenario_report_struct longtext NULL;
|
ALTER TABLE test_plan_report_content ADD plan_scenario_report_struct longtext NULL;
|
||||||
ALTER TABLE test_plan_report_content ADD plan_api_case_report_struct longtext NULL;
|
ALTER TABLE test_plan_report_content ADD plan_api_case_report_struct longtext NULL;
|
||||||
ALTER TABLE test_plan_report_content ADD plan_load_case_report_struct longtext NULL;
|
ALTER TABLE test_plan_report_content ADD plan_load_case_report_struct longtext NULL;
|
||||||
|
|
||||||
|
CREATE INDEX api_scenario_report_result_report_id_IDX ON api_scenario_report_result (report_id);
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue