refactor(接口定义): 重构列表查询sql 加速查询
This commit is contained in:
parent
49698e59af
commit
6d78a2ade9
|
@ -82,28 +82,16 @@
|
||||||
</sql>
|
</sql>
|
||||||
<sql id="Base_Column_List">
|
<sql id="Base_Column_List">
|
||||||
id, project_id, name,module_id,module_path,protocol ,path,method ,description, status, user_id, create_time, update_time
|
id, project_id, name,module_id,module_path,protocol ,path,method ,description, status, user_id, create_time, update_time
|
||||||
</sql>
|
</sql>
|
||||||
<sql id="Blob_Column_List">
|
<sql id="Blob_Column_List">
|
||||||
request
|
request
|
||||||
</sql>
|
</sql>
|
||||||
|
|
||||||
<select id="selectByIds" resultType="io.metersphere.api.dto.definition.ApiComputeResult">
|
<select id="selectByIds" resultType="io.metersphere.api.dto.definition.ApiComputeResult">
|
||||||
select t1.api_definition_id apiDefinitionId,count(t1.id) caseTotal,
|
SELECT t1.api_definition_id apiDefinitionId,count(t1.id) caseTotal,
|
||||||
case t2.status
|
CASE t2.STATUS WHEN 'success' THEN '通过' WHEN 'error' THEN '未通过' ELSE '未执行' END AS STATUS,CONCAT(FORMAT(SUM(IF (t2.`status`='success',1,0))/COUNT(t1.id)*100,2),'%') passRate
|
||||||
when 'success' then '通过'
|
FROM api_test_case t1
|
||||||
when 'error' then '未通过'
|
LEFT JOIN api_definition_exec_result t2 ON t1.last_result_id=t2.id
|
||||||
ELSE '未执行' end as status ,
|
|
||||||
CONCAT(FORMAT(SUM(IF(t2.`status` = 'success', 1, 0))/ COUNT(t1.id)*100, 2), '%') passRate
|
|
||||||
from api_test_case t1
|
|
||||||
left join (
|
|
||||||
select
|
|
||||||
max(create_time) create_time ,status ,id, resource_id
|
|
||||||
from
|
|
||||||
api_definition_exec_result
|
|
||||||
group by
|
|
||||||
resource_id
|
|
||||||
)as t2
|
|
||||||
on t1.id = t2.resource_id
|
|
||||||
group by t1.api_definition_id having t1.api_definition_id in
|
group by t1.api_definition_id having t1.api_definition_id in
|
||||||
<foreach collection="ids" item="v" separator="," open="(" close=")">
|
<foreach collection="ids" item="v" separator="," open="(" close=")">
|
||||||
#{v}
|
#{v}
|
||||||
|
@ -301,12 +289,12 @@
|
||||||
<if test="request.orders != null and request.orders.size() > 0">
|
<if test="request.orders != null and request.orders.size() > 0">
|
||||||
order by
|
order by
|
||||||
<foreach collection="request.orders" separator="," item="order">
|
<foreach collection="request.orders" separator="," item="order">
|
||||||
<if test="order.name == 'user_name'">
|
<if test="order.name == 'user_name'">
|
||||||
user_name ${order.type}
|
user_name ${order.type}
|
||||||
</if>
|
</if>
|
||||||
<if test="order.name != 'user_name'">
|
<if test="order.name != 'user_name'">
|
||||||
api_definition.${order.name} ${order.type}
|
api_definition.${order.name} ${order.type}
|
||||||
</if>
|
</if>
|
||||||
</foreach>
|
</foreach>
|
||||||
</if>
|
</if>
|
||||||
</select>
|
</select>
|
||||||
|
@ -413,15 +401,15 @@
|
||||||
</foreach>
|
</foreach>
|
||||||
</if>
|
</if>
|
||||||
and exists (
|
and exists (
|
||||||
select id
|
select id
|
||||||
from api_test_case c
|
from api_test_case c
|
||||||
where c.api_definition_id = api_definition.id
|
where c.api_definition_id = api_definition.id
|
||||||
and not exists (
|
and not exists (
|
||||||
select id
|
select 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.planId}
|
and t.test_plan_id = #{request.planId}
|
||||||
)
|
)
|
||||||
)
|
)
|
||||||
</where>
|
</where>
|
||||||
<if test="request.orders != null and request.orders.size() > 0">
|
<if test="request.orders != null and request.orders.size() > 0">
|
||||||
|
|
Loading…
Reference in New Issue