fix(测试跟踪): 首页评审状态统计有误
--bug=1023471 --user=陈建星 【测试跟踪】首页 - 用例评审 结果分布 统计错误 https://www.tapd.cn/55049933/s/1339979
This commit is contained in:
parent
8154c1a22d
commit
577e5c2d49
|
@ -794,7 +794,7 @@
|
|||
</sql>
|
||||
|
||||
<select id="countPriority" resultType="io.metersphere.dto.TrackCountResult">
|
||||
SELECT test_case.priority as groupField, count(DISTINCT ref_id) AS countNumber
|
||||
SELECT test_case.priority as groupField, count(id) AS countNumber
|
||||
FROM test_case
|
||||
WHERE project_id = #{projectId}
|
||||
AND test_case.status != 'Trash'
|
||||
|
|
|
@ -153,12 +153,12 @@ public class TrackStatisticsDTO {
|
|||
|
||||
public void countStatus(List<TrackCountResult> statusResults) {
|
||||
for (TrackCountResult countResult : statusResults) {
|
||||
if(TestReviewCaseStatus.Prepare.name().equals(countResult.getGroupField())){
|
||||
this.prepareCount += countResult.getCountNumber();
|
||||
}else if(TestReviewCaseStatus.Pass.name().equals(countResult.getGroupField())){
|
||||
if(TestReviewCaseStatus.Pass.name().equals(countResult.getGroupField())){
|
||||
this.passCount += countResult.getCountNumber();
|
||||
}else if(TestReviewCaseStatus.UnPass.name().equals(countResult.getGroupField())){
|
||||
} else if(TestReviewCaseStatus.UnPass.name().equals(countResult.getGroupField())){
|
||||
this.unPassCount += countResult.getCountNumber();
|
||||
} else {
|
||||
this.prepareCount += countResult.getCountNumber();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -166,33 +166,9 @@ public class TestCaseReviewService {
|
|||
if (CollectionUtils.isNotEmpty(caseList)) {
|
||||
Map<String, List<TestCaseReviewTestCase>> statusMap = caseList.stream()
|
||||
.collect(Collectors.groupingBy(TestCaseReviewTestCase::getStatus));
|
||||
|
||||
List<TestReviewCaseStatus> statusList = Arrays.stream(TestReviewCaseStatus.values())
|
||||
.sorted(Comparator.comparing(TestReviewCaseStatus::getOrder))
|
||||
.collect(Collectors.toList());
|
||||
|
||||
List<CountMapDTO> statusCountList = new ArrayList<>();
|
||||
|
||||
int passCount = 0;
|
||||
int total = 0;
|
||||
for (TestReviewCaseStatus status : statusList) {
|
||||
List<TestCaseReviewTestCase> statusCases = statusMap.get(status.name());
|
||||
if (CollectionUtils.isEmpty(statusCases)) {
|
||||
continue;
|
||||
}
|
||||
CountMapDTO countMapDTO = new CountMapDTO();
|
||||
countMapDTO.setKey(status.name());
|
||||
countMapDTO.setValue(statusCases.size());
|
||||
statusCountList.add(countMapDTO);
|
||||
total += statusCases.size();
|
||||
if (StringUtils.equals(status.name(), TestReviewCaseStatus.Pass.name())) {
|
||||
passCount = statusCases.size();
|
||||
}
|
||||
}
|
||||
item.setStatusCountItems(statusCountList);
|
||||
|
||||
item.setPassRate(MathUtils.getPercentWithDecimal(total == 0 ? 0 : passCount * 1.0 / total));
|
||||
item.setCaseCount(total);
|
||||
Map<String, Integer> statusSizeMap = new HashMap<>();
|
||||
statusMap.forEach((k, v) -> statusSizeMap.put(k, v.size()));
|
||||
doCalcReviewRate(item, statusSizeMap);
|
||||
} else {
|
||||
item.setPassRate(0d);
|
||||
item.setCaseCount(0);
|
||||
|
@ -200,6 +176,35 @@ public class TestCaseReviewService {
|
|||
});
|
||||
}
|
||||
|
||||
private void doCalcReviewRate(TestCaseReviewDTO review, Map<String, Integer> statusSizeMap) {
|
||||
List<TestReviewCaseStatus> statusList = Arrays.stream(TestReviewCaseStatus.values())
|
||||
.sorted(Comparator.comparing(TestReviewCaseStatus::getOrder))
|
||||
.collect(Collectors.toList());
|
||||
|
||||
List<CountMapDTO> statusCountList = new ArrayList<>();
|
||||
|
||||
int passCount = 0;
|
||||
int total = 0;
|
||||
for (TestReviewCaseStatus status : statusList) {
|
||||
Integer count = statusSizeMap.get(status.name());
|
||||
if (count == null) {
|
||||
continue;
|
||||
}
|
||||
CountMapDTO countMapDTO = new CountMapDTO();
|
||||
countMapDTO.setKey(status.name());
|
||||
countMapDTO.setValue(count);
|
||||
statusCountList.add(countMapDTO);
|
||||
total += count;
|
||||
if (StringUtils.equals(status.name(), TestReviewCaseStatus.Pass.name())) {
|
||||
passCount = count;
|
||||
}
|
||||
}
|
||||
review.setStatusCountItems(statusCountList);
|
||||
|
||||
review.setPassRate(MathUtils.getPercentWithDecimal(total == 0 ? 0 : passCount * 1.0 / total));
|
||||
review.setCaseCount(total);
|
||||
}
|
||||
|
||||
public List<Project> getProjectByReviewId(TestCaseReview request) {
|
||||
String reviewId = request.getId();
|
||||
|
||||
|
@ -613,21 +618,13 @@ public class TestCaseReviewService {
|
|||
testReview.setCreator(u.getName());
|
||||
}
|
||||
|
||||
Map<String, Integer> statusSizeMap = new HashMap<>();
|
||||
|
||||
countMapDTOS.forEach(item -> {
|
||||
testReview.setTotal(testReview.getTotal() + item.getValue());
|
||||
if (!StringUtils.equals(item.getKey(), TestReviewCaseStatus.Prepare.name()) && !StringUtils.equals(item.getKey(), TestReviewCaseStatus.Again.name()) ) {
|
||||
testReview.setReviewed(testReview.getReviewed() + item.getValue());
|
||||
}
|
||||
if (StringUtils.equals(item.getKey(), TestReviewCaseStatus.Pass.name())) {
|
||||
testReview.setPass(testReview.getPass() + item.getValue());
|
||||
}
|
||||
if (StringUtils.equals(item.getKey(), TestReviewCaseStatus.Prepare.name())) {
|
||||
testReview.setPrepare(testReview.getPrepare() + item.getValue());
|
||||
}
|
||||
if (StringUtils.equals(item.getKey(), TestReviewCaseStatus.Again.name())) {
|
||||
testReview.setAgain(testReview.getAgain() + item.getValue());
|
||||
}
|
||||
statusSizeMap.put(item.getKey(), item.getValue());
|
||||
});
|
||||
|
||||
doCalcReviewRate(testReview, statusSizeMap);
|
||||
});
|
||||
}
|
||||
return testReviews;
|
||||
|
|
|
@ -52,9 +52,9 @@
|
|||
show-overflow-tooltip
|
||||
width="350px">
|
||||
<template v-slot:default="scope">
|
||||
<el-tooltip :content="getResultTip(scope.row.total, scope.row.reviewed, scope.row.pass, scope.row.prepare, scope.row.again)"
|
||||
<el-tooltip :content="getResultTip(scope.row)"
|
||||
placement="top" :enterable="false" class="item" effect="dark">
|
||||
<yan-progress :total="scope.row.total" :done="scope.row.reviewed" :modify="scope.row.pass" :tip="tip"/>
|
||||
<yan-progress :total="scope.row.caseCount" :done="getResultCount(scope.row, 'Pass')" :modify="getResultCount(scope.row, 'UnPass')" :tip="tip"/>
|
||||
</el-tooltip>
|
||||
</template>
|
||||
</el-table-column>
|
||||
|
@ -142,8 +142,33 @@ export default {
|
|||
}
|
||||
this.search();
|
||||
},
|
||||
getResultTip(total, reviewed, pass, prepare, again) {
|
||||
return '通过: ' + pass + '; ' + '未通过: ' + (reviewed - pass) + '; ' + '未评审: ' + prepare + '; ' + '重新提审: ' + again;
|
||||
getNotDoneResultCount(row) {
|
||||
return this.getResultCount(row, 'Underway') + this.getResultCount(row, 'Again')
|
||||
},
|
||||
getResultCount(row, status) {
|
||||
if (row.statusCountItems) {
|
||||
let result = row.statusCountItems.filter(item => status === item.key);
|
||||
if (result && result.length > 0) {
|
||||
return result[0].value;
|
||||
}
|
||||
}
|
||||
return 0;
|
||||
},
|
||||
getResultTip(row) {
|
||||
if (row.statusCountItems) {
|
||||
let statusMap = {
|
||||
'Prepare': this.$t('test_track.review.prepare'),
|
||||
'Again': this.$t('test_track.review.again'),
|
||||
'Pass': this.$t('test_track.review.pass'),
|
||||
'UnPass': this.$t('test_track.review.un_pass'),
|
||||
'Underway': this.$t('test_track.review.underway'),
|
||||
}
|
||||
let tip = '';
|
||||
row.statusCountItems.forEach(item => {
|
||||
tip += statusMap[item.key] + item.value + ';';
|
||||
});
|
||||
return tip;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue