refactor(接口定义): 重构列表查询sql 加速查询
This commit is contained in:
parent
49698e59af
commit
6d78a2ade9
|
@ -88,22 +88,10 @@
|
||||||
</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}
|
||||||
|
|
Loading…
Reference in New Issue