refactor(接口测试): 优化报告查询sql

This commit is contained in:
fit2-zhao 2022-03-07 14:58:06 +08:00 committed by fit2-zhao
parent f9fa51dd6e
commit 4a54da4b21
1 changed files with 65 additions and 72 deletions

View File

@ -138,7 +138,6 @@
</sql>
<select id="list" resultMap="BaseResultMap">
select * from (
select * from (
SELECT s_r.name AS test_name,
s_r.end_time,
@ -197,16 +196,8 @@
</foreach>
</if>
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>
</where>
) apiScenarioReport
union
select * from (
union all
select a_r.name as test_name,
a_r.end_time,
a_r.user_id,
@ -247,30 +238,32 @@
#{value}
</foreach>
</when>
<when test="key=='report_type'">
and a_r.report_type in
<foreach collection="values" item="value" separator="," open="(" close=")">
#{value}
</foreach>
</when>
<otherwise>
<when test="key=='trigger_mode'">
and a_r.trigger_mode in
<foreach collection="values" item="value" separator="," open="(" close=")">
#{value}
</foreach>
</otherwise>
</when>
</choose>
</if>
</foreach>
</if>
<if test="request.orders != null and request.orders.size() > 0">
order by
<foreach collection="request.orders" separator="," item="order">
${order.name} ${order.type}
) r
where 1 = 1
<if test="request.filters != null and request.filters.size() > 0">
<foreach collection="request.filters.entrySet()" index="key" item="values">
<if test="values != null and values.size() > 0">
<choose>
<when test="key=='report_type'">
and r.report_type in
<foreach collection="values" item="value" separator="," open="(" close=")">
#{value}
</foreach>
</when>
</choose>
</if>
</foreach>
</if>
) apiDefinitionReport
) r
<if test="request.orders != null and request.orders.size() > 0">
order by
<foreach collection="request.orders" separator="," item="order">
@ -294,7 +287,7 @@
s_r.execute_type,
s_r.report_type
FROM api_scenario_report s_r
union
union all
select a_r.name as test_name,
a_r.end_time,
a_r.user_id,