fix: 用例统计排除已删除#1006893

--bug=1006893 --user=lyh 【github#6373】首页-用例数量统计中的数据统计不正确
https://www.tapd.cn/55049933/s/1051592
This commit is contained in:
shiziyuan9527 2021-09-26 11:16:13 +08:00 committed by shiziyuan9527
parent 742e604c05
commit 78def615ed
2 changed files with 9 additions and 10 deletions

View File

@ -390,39 +390,38 @@
GROUP BY test_case.priority
</select>
<!-- todo 排除删除的用例统计-->
<select id="countCreatedThisWeek" resultType="java.lang.Long">
SELECT count(id) AS countNumber FROM test_case WHERE test_case.project_id = #{projectId}
SELECT count(id) AS countNumber FROM test_case WHERE test_case.project_id = #{projectId} and test_case.status != 'Trash'
AND create_time BETWEEN #{firstDayTimestamp} AND #{lastDayTimestamp}
</select>
<!-- todo 排除删除的用例统计-->
<select id="countStatus" resultType="io.metersphere.track.response.TrackCountResult">
SELECT review_status AS groupField,count(id) AS countNumber FROM test_case WHERE project_id = #{projectId} GROUP BY test_case.review_status
SELECT review_status AS groupField,count(id) AS countNumber FROM test_case WHERE project_id = #{projectId} and test_case.status != 'Trash'
GROUP BY test_case.review_status
</select>
<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
FROM test_case join test_case_test on test_case.id = test_case_test.test_case_id
WHERE test_case.project_id = #{projectId} GROUP BY test_case_test.test_type
WHERE test_case.project_id = #{projectId} and test_case.status != 'Trash' GROUP BY test_case_test.test_type
</select>
<select id="countRelevanceCreatedThisWeek" resultType="java.lang.Long">
SELECT count(distinct test_case_test.test_case_id) AS countNumber FROM test_case join test_case_test on test_case.id = test_case_test.test_case_id
WHERE test_case.project_id = #{projectId}
WHERE test_case.project_id = #{projectId} and test_case.status != 'Trash'
AND test_case_test.create_time BETWEEN #{firstDayTimestamp} AND #{lastDayTimestamp}
</select>
<select id="countCoverage" resultType="int">
select count(test_case.id) from test_case where test_case.project_id = #{projectId}
select count(test_case.id) from test_case where test_case.project_id = #{projectId} and test_case.status != 'Trash'
and test_case.id in (select distinct test_case_test.test_case_id from test_case_test)
</select>
<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
where tc.project_id = #{projectId}
where tc.project_id = #{projectId} and tc.status != 'Trash'
group by tc.maintainer
</select>
<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
where tc.project_id = #{projectId} and tc.id in (select distinct test_case_test.test_case_id from test_case_test)
where tc.project_id = #{projectId} and tc.status != 'Trash' and tc.id in (select distinct test_case_test.test_case_id from test_case_test)
group by tc.maintainer
</select>
<select id="getTestPlanBug" resultType="int">

View File

@ -1493,7 +1493,7 @@ public class TestCaseService {
public List<TestCase> getTestCaseByProjectId(String projectId) {
TestCaseExample example = new TestCaseExample();
example.createCriteria().andProjectIdEqualTo(projectId);
example.createCriteria().andProjectIdEqualTo(projectId).andStatusNotEqualTo("Trash");
return testCaseMapper.selectByExample(example);
}