fix(测试跟踪): 首页遗留缺陷统计数量错误

--bug=1006831 --user=lyh 【测试跟踪】首页遗留缺陷统计数量错误
https://www.tapd.cn/55049933/s/1075503
This commit is contained in:
shiziyuan9527 2021-11-26 15:11:24 +08:00 committed by 刘瑞斌
parent 1654660213
commit 6cb5dcdc5d
5 changed files with 18 additions and 4 deletions

View File

@ -35,4 +35,6 @@ public interface ExtProjectMapper {
long getProjectMemberSize(@Param("projectId") String projectId);
List<Project>getProjectByUserId(@Param("userId")String userId);
int getProjectPlanBugSize(@Param("projectId") String projectId);
}

View File

@ -244,4 +244,11 @@
<select id="getProjectByUserId" resultType="io.metersphere.base.domain.Project">
SELECT * from project where project.id in (SELECT user_group.source_id from user_group where user_group.user_id = #{userId})
</select>
<select id="getProjectPlanBugSize" resultType="java.lang.Integer">
select count(distinct(tci.issues_id)) from test_plan_test_case tptc
join test_case_issues tci on tptc.case_id = tci.test_case_id
join issues on tci.issues_id = issues.id
join test_plan on tptc.plan_id = test_plan.id
where test_plan.project_id = #{projectId} and (issues.status != 'closed' or issues.status is null);
</select>
</mapper>

View File

@ -441,7 +441,7 @@
</select>
<select id="getTestPlanBug" resultType="int">
select count(tci.issues_id) from test_plan_test_case tptc join test_case_issues tci on tptc.case_id = tci.test_case_id join issues on tci.issues_id = issues.id
where tptc.plan_id = #{planId} and issues.status != 'closed';
where tptc.plan_id = #{planId} and (issues.status != 'closed' or issues.status is null);
</select>
<select id="getTestPlanCase" resultType="int">
select count(s)

View File

@ -745,4 +745,8 @@ public class ProjectService {
public long getProjectMemberSize(String id) {
return extProjectMapper.getProjectMemberSize(id);
}
public int getProjectBugSize(String projectId) {
return extProjectMapper.getProjectPlanBugSize(projectId);
}
}

View File

@ -9,6 +9,7 @@ import io.metersphere.commons.constants.TestPlanTestCaseStatus;
import io.metersphere.commons.utils.DateUtils;
import io.metersphere.commons.utils.MathUtils;
import io.metersphere.performance.base.ChartsData;
import io.metersphere.service.ProjectService;
import io.metersphere.track.dto.TestPlanDTOWithMetric;
import io.metersphere.track.response.BugStatustics;
import io.metersphere.track.response.TestPlanBugCount;
@ -40,6 +41,8 @@ public class TrackService {
private TestPlanScenarioCaseService testPlanScenarioCaseService;
@Resource
private TestPlanLoadCaseService testPlanLoadCaseService;
@Resource
private ProjectService projectService;
public List<TrackCountResult> countPriority(String projectId) {
return extTestCaseMapper.countPriority(projectId);
@ -115,7 +118,6 @@ public class TrackService {
List<TestPlanBugCount> list = new ArrayList<>();
BugStatustics bugStatustics = new BugStatustics();
int index = 1;
int totalBugSize = 0;
int totalCaseSize = 0;
for (TestPlan plan : plans) {
int planBugSize = getPlanBugSize(plan.getId());
@ -137,12 +139,11 @@ public class TrackService {
double planPassRage = getPlanPassRage(plan.getId());
testPlanBug.setPassRage(planPassRage + "%");
list.add(testPlanBug);
totalBugSize += planBugSize;
totalCaseSize += planCaseSize;
}
int totalBugSize = projectService.getProjectBugSize(projectId);
bugStatustics.setList(list);
float rage =totalCaseSize == 0 ? 0 : (float) totalBugSize * 100 / totalCaseSize;
DecimalFormat df = new DecimalFormat("0.0");