fix(测试跟踪): 测试跟踪首页关联用例数量统计忽略掉回收站中的接口和场景

--bug=1015414 --user=宋天阳 【测试跟踪】首页-关联用例数量统计,统计了回收站中的接口用例和场景
https://www.tapd.cn/55049933/s/1212890
This commit is contained in:
song-tianyang 2022-07-26 23:23:38 +08:00 committed by 建国
parent 41fa8c8839
commit 35d78b367f
1 changed files with 223 additions and 138 deletions

View File

@ -78,9 +78,9 @@
</if> </if>
<if test='${condition}.tags != null and ${objectKey}.operator == "not like"'> <if test='${condition}.tags != null and ${objectKey}.operator == "not like"'>
and (test_case.tags is null or test_case.tags and (test_case.tags is null or test_case.tags
<include refid="io.metersphere.base.mapper.ext.ExtBaseMapper.condition"> <include refid="io.metersphere.base.mapper.ext.ExtBaseMapper.condition">
<property name="object" value="${condition}.tags"/> <property name="object" value="${condition}.tags"/>
</include> </include>
) )
</if> </if>
<if test='${condition}.tags != null and ${objectKey}.operator == "like"'> <if test='${condition}.tags != null and ${objectKey}.operator == "like"'>
@ -109,36 +109,39 @@
<if test="${condition}.customs != null and ${condition}.customs.size() > 0"> <if test="${condition}.customs != null and ${condition}.customs.size() > 0">
<foreach collection="${condition}.customs" item="custom" separator="" open="" close=""> <foreach collection="${condition}.customs" item="custom" separator="" open="" close="">
and test_case.id in ( and test_case.id in (
select resource_id from custom_field_test_case where field_id = #{custom.id} select resource_id from custom_field_test_case where field_id = #{custom.id}
<choose> <choose>
<when test="custom.type == 'multipleMember' or custom.type == 'checkbox' or custom.type == 'multipleSelect'"> <when test="custom.type == 'multipleMember' or custom.type == 'checkbox' or custom.type == 'multipleSelect'">
and JSON_CONTAINS(`value`, #{custom.value}) and JSON_CONTAINS(`value`, #{custom.value})
</when> </when>
<when test="custom.type == 'date' or custom.type == 'datetime'"> <when test="custom.type == 'date' or custom.type == 'datetime'">
and left(replace(unix_timestamp(trim(both '"' from `value`)), '.', ''), 13) and left(replace(unix_timestamp(trim(both '"' from `value`)), '.', ''), 13)
<include refid="io.metersphere.base.mapper.ext.ExtBaseMapper.condition"> <include refid="io.metersphere.base.mapper.ext.ExtBaseMapper.condition">
<property name="object" value="custom"/> <property name="object" value="custom"/>
</include> </include>
</when> </when>
<when test="custom.type == 'richText' or custom.type == 'textarea'"> <when test="custom.type == 'richText' or custom.type == 'textarea'">
and text_value and text_value
<include refid="io.metersphere.base.mapper.ext.ExtBaseMapper.condition"> <include refid="io.metersphere.base.mapper.ext.ExtBaseMapper.condition">
<property name="object" value="custom"/> <property name="object" value="custom"/>
</include> </include>
</when> </when>
<otherwise> <otherwise>
and trim(both '"' from value) and trim(both '"' from value)
<include refid="io.metersphere.base.mapper.ext.ExtBaseMapper.condition"> <include refid="io.metersphere.base.mapper.ext.ExtBaseMapper.condition">
<property name="object" value="custom"/> <property name="object" value="custom"/>
</include> </include>
</otherwise> </otherwise>
</choose> </choose>
) )
</foreach> </foreach>
</if> </if>
</sql> </sql>
<update id="updateTestCaseCustomNumByProjectId"> <update id="updateTestCaseCustomNumByProjectId">
update test_case set custom_num = num where (custom_num is null or custom_num = '') and project_id = #{projectId} update test_case
set custom_num = num
where (custom_num is null or custom_num = '')
and project_id = #{projectId}
</update> </update>
<select id="getTestCaseByNotInReview" resultType="io.metersphere.track.dto.TestCaseDTO"> <select id="getTestCaseByNotInReview" resultType="io.metersphere.track.dto.TestCaseDTO">
select select
@ -151,7 +154,8 @@
project_version.id as versionId project_version.id as versionId
from test_case from test_case
left join test_case_review_test_case as T2 on test_case.id=T2.case_id and T2.review_id =#{request.reviewId} left join test_case_review_test_case as T2 on test_case.id=T2.case_id and T2.review_id =#{request.reviewId}
left join project_version on test_case.version_id = project_version.id and test_case.project_id = project_version.project_id left join project_version on test_case.version_id = project_version.id and test_case.project_id =
project_version.project_id
<include refid="notInQueryWhereCondition"/> <include refid="notInQueryWhereCondition"/>
and T2.case_id is null and T2.case_id is null
<include refid="io.metersphere.base.mapper.ext.ExtBaseMapper.orders"/> <include refid="io.metersphere.base.mapper.ext.ExtBaseMapper.orders"/>
@ -214,7 +218,8 @@
</select> </select>
<select id="getTestCaseNames" resultType="io.metersphere.base.domain.TestCase"> <select id="getTestCaseNames" resultType="io.metersphere.base.domain.TestCase">
select test_case.id, test_case.name, test_case.priority, test_case.type, test_case.review_status,test_case.num,test_case.custom_num select test_case.id, test_case.name, test_case.priority, test_case.type,
test_case.review_status,test_case.num,test_case.custom_num
from test_case from test_case
<where> <where>
<if test="request.combine != null"> <if test="request.combine != null">
@ -268,7 +273,7 @@
</select> </select>
<select id="publicList" resultType="io.metersphere.track.dto.TestCaseDTO"> <select id="publicList" resultType="io.metersphere.track.dto.TestCaseDTO">
select select
test_case.last_execute_result, test_case.last_execute_result,
<if test="request.selectFields != null and request.selectFields.size() > 0"> <if test="request.selectFields != null and request.selectFields.size() > 0">
<foreach collection="request.selectFields" item="field" separator=","> <foreach collection="request.selectFields" item="field" separator=",">
@ -276,7 +281,8 @@
</foreach> </foreach>
</if> </if>
<if test="request.selectFields == null or request.selectFields.size() == 0"> <if test="request.selectFields == null or request.selectFields.size() == 0">
test_case.id, test_case.node_id, test_case.node_path, test_case.project_id, test_case.`name`, test_case.version_id, test_case.id, test_case.node_id, test_case.node_path, test_case.project_id, test_case.`name`,
test_case.version_id,
test_case.`type`, test_case.maintainer, test_case.priority, test_case.`method`, test_case.`type`, test_case.maintainer, test_case.priority, test_case.`method`,
test_case.create_time, test_case.update_time, test_case.test_id, test_case.sort, test_case.num, test_case.create_time, test_case.update_time, test_case.test_id, test_case.sort, test_case.num,
test_case.other_test_name, test_case.review_status, test_case.tags, test_case.other_test_name, test_case.review_status, test_case.tags,
@ -325,7 +331,8 @@
<select id="getTestReviewRelateCountNodes" resultType="io.metersphere.track.dto.TestCaseNodeDTO"> <select id="getTestReviewRelateCountNodes" resultType="io.metersphere.track.dto.TestCaseNodeDTO">
select tcn.id, count(*) as caseNum, test_case.project_id select tcn.id, count(*) as caseNum, test_case.project_id
from test_case from test_case
left join test_case_review_test_case tcrtc on tcrtc.case_id = test_case.id and tcrtc.review_id = #{request.reviewId} left join test_case_review_test_case tcrtc on tcrtc.case_id = test_case.id and tcrtc.review_id =
#{request.reviewId}
left join test_case_node tcn on test_case.node_id = tcn.id left join test_case_node tcn on test_case.node_id = tcn.id
<include refid="queryWhereCondition"/> <include refid="queryWhereCondition"/>
and tcrtc.case_id is null and tcrtc.case_id is null
@ -333,15 +340,18 @@
</select> </select>
<select id="listByMethod" resultType="io.metersphere.track.dto.TestCaseDTO"> <select id="listByMethod" resultType="io.metersphere.track.dto.TestCaseDTO">
select load_test.id, load_test.name, load_test.project_id,'性能测试' as type, project_version.name as version_name select load_test.id, load_test.name, load_test.project_id,'性能测试' as type, project_version.name as version_name
from load_test inner join project_version on project_version.project_id = load_test.project_id and project_version.id = load_test.version_id from load_test inner join project_version on project_version.project_id = load_test.project_id and
project_version.id = load_test.version_id
<where> <where>
<if test="request.projectId!=null"> <if test="request.projectId!=null">
and load_test.project_id= #{request.projectId} and load_test.project_id= #{request.projectId}
</if> </if>
</where> </where>
UNION ALL UNION ALL
select api_scenario.id, api_scenario.name, api_scenario.project_id,'接口场景' as type, project_version.name as version_name select api_scenario.id, api_scenario.name, api_scenario.project_id,'接口场景' as type, project_version.name as
from api_scenario inner join project_version on project_version.project_id = api_scenario.project_id and project_version.id = api_scenario.version_id version_name
from api_scenario inner join project_version on project_version.project_id = api_scenario.project_id and
project_version.id = api_scenario.version_id
<where> <where>
<if test="request.projectId!=null"> <if test="request.projectId!=null">
and api_scenario.project_id= #{request.projectId} and api_scenario.project_id= #{request.projectId}
@ -350,7 +360,7 @@
and api_scenario.status!='Trash' and api_scenario.status!='Trash'
UNION ALL UNION ALL
select b.id,b.name,b.project_id,'接口用例' as type, project_version.name as version_name select b.id,b.name,b.project_id,'接口用例' as type, project_version.name as version_name
from api_test_case b inner join api_definition a on b.api_definition_id = a.id and a.status != 'Trash' from api_test_case b inner join api_definition a on b.api_definition_id = a.id and a.status != 'Trash'
inner join project_version on project_version.project_id = a.project_id and project_version.id = a.version_id inner join project_version on project_version.project_id = a.project_id and project_version.id = a.version_id
<where> <where>
<if test="request.projectId!=null"> <if test="request.projectId!=null">
@ -375,7 +385,7 @@
<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">
`${order.name}` ${order.type} `${order.name}` ${order.type}
</foreach> </foreach>
</if> </if>
</select> </select>
@ -384,8 +394,7 @@
SELECT * SELECT *
FROM test_case FROM test_case
WHERE test_case.project_id = #{projectId} WHERE test_case.project_id = #{projectId}
ORDER BY num DESC ORDER BY num DESC LIMIT 1;
LIMIT 1;
</select> </select>
<select id="checkIsHave" resultType="int"> <select id="checkIsHave" resultType="int">
@ -580,9 +589,9 @@
</when> </when>
<when test="key.startsWith('custom')"> <when test="key.startsWith('custom')">
and test_case.id in ( and test_case.id in (
select resource_id from custom_field_test_case where concat('custom',field_id) = #{key} select resource_id from custom_field_test_case where concat('custom',field_id) = #{key}
and trim(both '"' from value) in and trim(both '"' from value) in
<include refid="io.metersphere.base.mapper.ext.ExtBaseMapper.filterInWrapper"/> <include refid="io.metersphere.base.mapper.ext.ExtBaseMapper.filterInWrapper"/>
) )
</when> </when>
<when test="key=='create_user'"> <when test="key=='create_user'">
@ -657,10 +666,28 @@
</if> </if>
<include refid="filters"/> <include refid="filters"/>
<if test="request.caseCoverage == 'uncoverage' "> <if test="request.caseCoverage == 'uncoverage' ">
and test_case.id not in (select distinct test_case_test.test_case_id from test_case_test) and test_case.id not in (
SELECT test_case_id FROM test_case_test WHERE test_type = 'testCase' and test_id IN (select id FROM
api_test_case WHERE `STATUS` is null or status != 'Trash')
UNION
SELECT test_case_id FROM test_case_test WHERE test_type = 'performance' and test_id IN (select id from
load_test)
UNION
SELECT test_case_id FROM test_case_test WHERE test_type = 'automation' and test_id IN (select id FROM
api_scenario WHERE `STATUS` != 'Trash')
)
</if> </if>
<if test="request.caseCoverage == 'coverage' "> <if test="request.caseCoverage == 'coverage' ">
and test_case.id in (select distinct test_case_test.test_case_id from test_case_test) and test_case.id in (
SELECT test_case_id FROM test_case_test WHERE test_type = 'testCase' and test_id IN (select id FROM
api_test_case WHERE `STATUS` is null or status != 'Trash')
UNION
SELECT test_case_id FROM test_case_test WHERE test_type = 'performance' and test_id IN (select id from
load_test)
UNION
SELECT test_case_id FROM test_case_test WHERE test_type = 'automation' and test_id IN (select id FROM
api_scenario WHERE `STATUS` != 'Trash')
)
</if> </if>
<include refid="queryVersionCondition"> <include refid="queryVersionCondition">
<property name="versionTable" value="test_case"/> <property name="versionTable" value="test_case"/>
@ -733,44 +760,94 @@
SELECT test_case.priority as groupField, count(DISTINCT ref_id) AS countNumber SELECT test_case.priority as groupField, count(DISTINCT ref_id) AS countNumber
FROM test_case FROM test_case
WHERE project_id = #{projectId} WHERE project_id = #{projectId}
AND test_case.status != 'Trash' AND test_case.status != 'Trash'
and latest = true and latest = true
GROUP BY test_case.priority GROUP BY test_case.priority
</select> </select>
<select id="countCreatedThisWeek" resultType="java.lang.Long"> <select id="countCreatedThisWeek" resultType="java.lang.Long">
SELECT count(DISTINCT ref_id) AS countNumber FROM test_case WHERE test_case.project_id = #{projectId} and test_case.status != 'Trash' and latest = 1 SELECT count(DISTINCT ref_id) AS countNumber
AND create_time BETWEEN #{firstDayTimestamp} AND #{lastDayTimestamp} FROM test_case
WHERE test_case.project_id = #{projectId}
and test_case.status != 'Trash' and latest = 1
AND create_time BETWEEN #{firstDayTimestamp}
AND #{lastDayTimestamp}
</select> </select>
<select id="countStatus" resultType="io.metersphere.track.response.TrackCountResult"> <select id="countStatus" resultType="io.metersphere.track.response.TrackCountResult">
SELECT review_status AS groupField,count(id) AS countNumber FROM test_case SELECT review_status AS groupField, count(id) AS countNumber
WHERE project_id = #{projectId} and test_case.status != 'Trash' and latest = 1 FROM test_case
WHERE project_id = #{projectId}
and test_case.status != 'Trash' and latest = 1
GROUP BY test_case.review_status GROUP BY test_case.review_status
</select> </select>
<select id="countRelevance" resultType="io.metersphere.track.response.TrackCountResult"> <select id="countRelevance" resultType="io.metersphere.track.response.TrackCountResult">
SELECT test_case_test.test_type AS groupField, count(test_case_test.test_case_id) AS countNumber SELECT test_case_test.test_type AS groupField,
FROM test_case join test_case_test on test_case.id = test_case_test.test_case_id count(test_case_test.test_case_id) AS countNumber
WHERE test_case.project_id = #{projectId} and test_case.status != 'Trash' and latest = 1 GROUP BY test_case_test.test_type FROM test_case
INNER JOIN (SELECT test_case_id, test_id, test_type
FROM test_case_test
WHERE test_type = 'testCase'
and test_id IN (select id FROM api_test_case WHERE `STATUS` is null or status != 'Trash')
UNION
SELECT test_case_id, test_id, test_type
FROM test_case_test
WHERE test_type = 'performance'
and test_id IN (select id from load_test)
UNION
SELECT test_case_id, test_id, test_type
FROM test_case_test
WHERE test_type = 'automation'
and test_id IN (select id FROM api_scenario WHERE `STATUS` != 'Trash')
)
test_case_test
ON test_case.id = test_case_test.test_case_id
WHERE
test_case.project_id = #{projectId}
AND test_case.STATUS != 'Trash'
AND latest = 1
GROUP BY
test_case_test.test_type
</select> </select>
<select id="countRelevanceCreatedThisWeek" resultType="java.lang.Long"> <select id="countRelevanceCreatedThisWeek" resultType="java.lang.Long">
SELECT count(distinct test_case.ref_id) AS countNumber FROM test_case join test_case_test on test_case.id = test_case_test.test_case_id SELECT count(distinct test_case.ref_id) AS countNumber
WHERE test_case.project_id = #{projectId} and test_case.status != 'Trash' and latest = 1 FROM test_case
AND test_case_test.create_time BETWEEN #{firstDayTimestamp} AND #{lastDayTimestamp} join test_case_test on test_case.id = test_case_test.test_case_id
WHERE test_case.project_id = #{projectId}
and test_case.status != 'Trash' and latest = 1
AND test_case_test.create_time BETWEEN #{firstDayTimestamp}
AND #{lastDayTimestamp}
</select> </select>
<select id="countCoverage" resultType="int"> <select id="countCoverage" resultType="int">
select count(test_case.id) from test_case where test_case.project_id = #{projectId} and test_case.status != 'Trash' and latest = 1 select count(test_case.id)
and test_case.id in (select distinct test_case_test.test_case_id from test_case_test) from test_case
where test_case.project_id = #{projectId}
and test_case.status != 'Trash' and latest = 1
and test_case.id in (
SELECT test_case_id FROM test_case_test WHERE test_type = 'testCase' and test_id IN (select id FROM
api_test_case WHERE `STATUS` is null or status != 'Trash')
UNION
SELECT test_case_id FROM test_case_test WHERE test_type = 'performance' and test_id IN (select id from load_test)
UNION
SELECT test_case_id FROM test_case_test WHERE test_type = 'automation' and test_id IN (select id FROM
api_scenario WHERE `STATUS` != 'Trash')
)
</select> </select>
<select id="countFuncMaintainer" resultType="io.metersphere.track.response.TrackCountResult"> <select id="countFuncMaintainer" resultType="io.metersphere.track.response.TrackCountResult">
select count(tc.id) as countNumber, user.name as groupField from test_case tc right join user on tc.maintainer = user.id select count(tc.id) as countNumber, user.name as groupField
where tc.project_id = #{projectId} and tc.status != 'Trash' and tc.latest = 1 from test_case tc
right join user on tc.maintainer = user.id
where tc.project_id = #{projectId}
and tc.status != 'Trash' and tc.latest = 1
group by tc.maintainer group by tc.maintainer
</select> </select>
<select id="countRelevanceMaintainer" resultType="io.metersphere.track.response.TrackCountResult"> <select id="countRelevanceMaintainer" resultType="io.metersphere.track.response.TrackCountResult">
select count(tc.id) as countNumber, user.name as groupField from test_case tc right join user on tc.maintainer = user.id select count(tc.id) as countNumber, user.name as groupField
where tc.project_id = #{projectId} and tc.status != 'Trash' and tc.latest = 1 and tc.id in (select distinct test_case_test.test_case_id from test_case_test) from test_case tc
right join user on tc.maintainer = user.id
where tc.project_id = #{projectId}
and tc.status != 'Trash' and tc.latest = 1 and tc.id in (select distinct test_case_test.test_case_id from test_case_test)
group by tc.maintainer group by tc.maintainer
</select> </select>
<select id="getTestPlanBug" resultType="int"> <select id="getTestPlanBug" resultType="int">
@ -788,50 +865,57 @@
</select> </select>
<select id="getTestPlanCase" resultType="int"> <select id="getTestPlanCase" resultType="int">
select count(s) select count(s)
from ( from (select tptc.id as s
select tptc.id as s from test_plan_test_case tptc
from test_plan_test_case tptc join test_case on tptc.case_id = test_case.id join test_case on tptc.case_id = test_case.id
where tptc.plan_id = #{planId} and (test_case.status != 'Trash' or test_case.status is null) where tptc.plan_id = #{planId}
and (test_case.status != 'Trash' or test_case.status is null)
union all union all
select tpas.id as s select tpas.id as s
from test_plan_api_scenario tpas join api_scenario on tpas.api_scenario_id = api_scenario.id from test_plan_api_scenario tpas
where tpas.test_plan_id = #{planId} and (api_scenario.status != 'Trash' or api_scenario.status is null) join api_scenario on tpas.api_scenario_id = api_scenario.id
where tpas.test_plan_id = #{planId}
and (api_scenario.status != 'Trash' or api_scenario.status is null)
union all union all
select tpac.id as s select tpac.id as s
from test_plan_api_case tpac join api_test_case on tpac.api_case_id = api_test_case.id from test_plan_api_case tpac
join api_definition on api_test_case.api_definition_id = api_definition.id join api_test_case on tpac.api_case_id = api_test_case.id
where tpac.test_plan_id = #{planId} and (api_definition.status != 'Trash' or api_definition.status is null) join api_definition on api_test_case.api_definition_id = api_definition.id
where tpac.test_plan_id = #{planId}
and (api_definition.status != 'Trash' or api_definition.status is null)
union all union all
select tplc.id as s select tplc.id as s
from test_plan_load_case tplc join load_test on tplc.load_case_id = load_test.id from test_plan_load_case tplc
where tplc.test_plan_id = #{planId} join load_test on tplc.load_case_id = load_test.id
) as temp where tplc.test_plan_id = #{planId}) as temp
</select> </select>
<select id="getTestPlanPassCase" resultType="int"> <select id="getTestPlanPassCase" resultType="int">
select count(s) select count(s)
from ( from (select id as s
select id as s from test_plan_test_case tptc
from test_plan_test_case tptc where tptc.plan_id = #{planId}
where tptc.plan_id = #{planId} and tptc.status = 'Pass' and tptc.status = 'Pass'
union all union all
select id as s select id as s
from test_plan_api_scenario tpas from test_plan_api_scenario tpas
where tpas.test_plan_id = #{planId} and tpas.last_result = 'Success' where tpas.test_plan_id = #{planId}
union all and tpas.last_result = 'Success'
select id as s union all
from test_plan_api_case tpac select id as s
where tpac.test_plan_id = #{planId} and tpac.status = 'success' from test_plan_api_case tpac
union all where tpac.test_plan_id = #{planId}
select id as s and tpac.status = 'success'
from test_plan_load_case tplc union all
where tplc.test_plan_id = #{planId} and tplc.status = 'success' select id as s
) as temp from test_plan_load_case tplc
where tplc.test_plan_id = #{planId}
and tplc.status = 'success') as temp
</select> </select>
<select id="listForMinder" resultType="io.metersphere.track.dto.TestCaseDTO"> <select id="listForMinder" resultType="io.metersphere.track.dto.TestCaseDTO">
@ -894,13 +978,19 @@
</where> </where>
</select> </select>
<select id="getTestCaseStep" resultType="io.metersphere.base.domain.TestCaseWithBLOBs"> <select id="getTestCaseStep" resultType="io.metersphere.base.domain.TestCaseWithBLOBs">
select id, prerequisite, steps, step_description, expected_result, step_model from test_case where id = #{id} select id, prerequisite, steps, step_description, expected_result, step_model
from test_case
where id = #{id}
</select> </select>
<select id="selectProjectIds" resultType="java.lang.String"> <select id="selectProjectIds" resultType="java.lang.String">
select DISTINCT project_id from test_case; select DISTINCT project_id
from test_case;
</select> </select>
<select id="getIdsOrderByUpdateTime" resultType="java.lang.String"> <select id="getIdsOrderByUpdateTime" resultType="java.lang.String">
select id from test_case where project_id = #{projectId} order by update_time ASC; select id
from test_case
where project_id = #{projectId}
order by update_time ASC;
</select> </select>
<select id="getLastOrder" resultType="java.lang.Long"> <select id="getLastOrder" resultType="java.lang.Long">
@ -934,7 +1024,8 @@
project_version.id versionId project_version.id versionId
FROM FROM
test_case AS test_case test_case AS test_case
inner join project_version on project_version.project_id = test_case.project_id and project_version.id = test_case.version_id inner join project_version on project_version.project_id = test_case.project_id and project_version.id =
test_case.version_id
<include refid="notInQueryWhereCondition"></include> <include refid="notInQueryWhereCondition"></include>
<include refid="io.metersphere.base.mapper.ext.ExtBaseMapper.orders"/> <include refid="io.metersphere.base.mapper.ext.ExtBaseMapper.orders"/>
</select> </select>
@ -961,27 +1052,27 @@
<update id="deleteToGc"> <update id="deleteToGc">
update test_case update test_case
set original_status=status, set original_status=status,
status = 'Trash', status = 'Trash',
delete_time = #{request.deleteTime}, delete_time = #{request.deleteTime},
delete_user_id = #{request.deleteUserId} delete_user_id = #{request.deleteUserId}
where ref_id in ( where ref_id in (
select a.ref_id from ( select a.ref_id from (
select ref_id from test_case select ref_id from test_case
<where> <where>
<if test="request.id != null and request.id != ''"> <if test="request.id != null and request.id != ''">
id = #{request.id} id = #{request.id}
</if> </if>
<if test="request.ids != null and request.ids.size() != 0"> <if test="request.ids != null and request.ids.size() != 0">
and id in and id in
<foreach collection="request.ids" item="id" separator="," open="(" close=")"> <foreach collection="request.ids" item="id" separator="," open="(" close=")">
#{id} #{id}
</foreach> </foreach>
</if> </if>
</where> </where>
) a ) a
) )
</update> </update>
<update id="deletePublic"> <update id="deletePublic">
@ -992,7 +1083,7 @@
ref_id =#{request.refId} ref_id =#{request.refId}
</if> </if>
<if test="request.versionId != null"> <if test="request.versionId != null">
and version_id =#{request.versionId} and version_id =#{request.versionId}
</if> </if>
</where> </where>
</update> </update>
@ -1027,21 +1118,17 @@
<select id="countByWorkSpaceId" resultType="java.lang.Integer"> <select id="countByWorkSpaceId" resultType="java.lang.Integer">
select count(distinct ref_id) select count(distinct ref_id)
from test_case from test_case
where project_id in ( where project_id in (select id
select id from project
from project where workspace_id = #{workSpaceId})
where workspace_id = #{workSpaceId})
and case_public = true and case_public = true
and test_case.status != 'Trash' and test_case.status != 'Trash'
</select> </select>
<select id="trashCount" resultType="java.lang.Long"> <select id="trashCount" resultType="java.lang.Long">
SELECT SELECT count(DISTINCT ref_id)
count(DISTINCT ref_id) FROM test_case
FROM WHERE project_id = #{projectId}
test_case
WHERE
project_id = #{projectId}
AND STATUS = 'Trash' AND STATUS = 'Trash'
</select> </select>
@ -1060,12 +1147,10 @@
<select id="selectRefIdsForVersionChange" resultType="java.lang.String"> <select id="selectRefIdsForVersionChange" resultType="java.lang.String">
SELECT DISTINCT ref_id SELECT DISTINCT ref_id
FROM test_case FROM test_case
WHERE ref_id NOT IN ( WHERE ref_id NOT IN (SELECT DISTINCT ref_id
SELECT DISTINCT ref_id FROM test_case
FROM test_case WHERE version_id = #{versionId}
WHERE version_id = #{versionId} AND project_id = #{projectId})
AND project_id = #{projectId}
)
AND project_id = #{projectId} AND project_id = #{projectId}
</select> </select>
<select id="getMaintainerMap" resultType="io.metersphere.base.domain.TestCase"> <select id="getMaintainerMap" resultType="io.metersphere.base.domain.TestCase">
@ -1087,8 +1172,8 @@
<select id="getForCompatibleCustomField" resultType="io.metersphere.track.dto.CustomFieldResourceCompatibleDTO"> <select id="getForCompatibleCustomField" resultType="io.metersphere.track.dto.CustomFieldResourceCompatibleDTO">
select id, custom_fields select id, custom_fields
from test_case from test_case
where project_id = #{projectId} where project_id = #{projectId} limit #{offset}
limit #{offset},#{pageSize} , #{pageSize}
</select> </select>
<update id="addLatestVersion"> <update id="addLatestVersion">