fix(测试跟踪): 首页重构
This commit is contained in:
parent
84a989db63
commit
19d284a399
|
@ -71,5 +71,10 @@ public interface ExtTestCaseMapper {
|
|||
|
||||
List<TrackCountResult> countRelevanceMaintainer(@Param("projectId") String projectId);
|
||||
|
||||
int getTestPlanBug(@Param("planId") String planId);
|
||||
int getTestPlanCase(@Param("planId") String planId);
|
||||
int getTestPlanPassCase(@Param("planId") String planId);
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
|
|
@ -342,8 +342,9 @@
|
|||
</select>
|
||||
|
||||
<select id="countCoverage" resultType="io.metersphere.track.response.TrackCountResult">
|
||||
SELECT count(test_case.id) AS countNumber, if(test_case.test_id is null,"uncoverage","coverage") AS groupField
|
||||
FROM test_case WHERE test_case.project_id=#{projectId} GROUP BY groupField
|
||||
SELECT count(test_case.id) AS countNumber,
|
||||
if(test_case.test_id is null,"uncoverage","coverage") AS groupField
|
||||
FROM test_case WHERE test_case.project_id=#{projectId} and test_case.type != 'functional' GROUP BY groupField
|
||||
</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
|
||||
|
@ -355,6 +356,50 @@
|
|||
where tc.project_id = #{projectId} and tc.test_id is not null
|
||||
group by tc.maintainer
|
||||
</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
|
||||
where tptc.plan_id = #{planId};
|
||||
</select>
|
||||
<select id="getTestPlanCase" resultType="int">
|
||||
select count(s)
|
||||
from (
|
||||
select id as s
|
||||
from test_plan_test_case tptc
|
||||
where tptc.plan_id = #{planId}
|
||||
union all
|
||||
select id as s
|
||||
from test_plan_api_scenario tpas
|
||||
where tpas.test_plan_id = #{planId}
|
||||
union all
|
||||
select id as s
|
||||
from test_plan_api_case tpac
|
||||
where tpac.test_plan_id = #{planId}
|
||||
union all
|
||||
select id as s
|
||||
from test_plan_load_case tplc
|
||||
where tplc.test_plan_id = #{planId}
|
||||
) as temp
|
||||
</select>
|
||||
<select id="getTestPlanPassCase" resultType="int">
|
||||
select count(s)
|
||||
from (
|
||||
select id as s
|
||||
from test_plan_test_case tptc
|
||||
where tptc.plan_id = #{planId} and tptc.status = 'Pass'
|
||||
union all
|
||||
select id as s
|
||||
from test_plan_api_scenario tpas
|
||||
where tpas.test_plan_id = #{planId} and tpas.last_result = 'Success'
|
||||
union all
|
||||
select id as s
|
||||
from test_plan_api_case tpac
|
||||
where tpac.test_plan_id = #{planId} and tpac.status = 'success'
|
||||
union all
|
||||
select id as s
|
||||
from test_plan_load_case tplc
|
||||
where tplc.test_plan_id = #{planId} and tplc.status = 'success'
|
||||
) as temp
|
||||
</select>
|
||||
|
||||
|
||||
</mapper>
|
|
@ -87,7 +87,7 @@ public class TrackController {
|
|||
}
|
||||
|
||||
@GetMapping("/bug/count/{projectId}")
|
||||
public BugStatustics getBugStatustics(@PathVariable String projectId) {
|
||||
return trackService.getBugStatustics(projectId);
|
||||
public BugStatustics getBugStatistics(@PathVariable String projectId) {
|
||||
return trackService.getBugStatistics(projectId);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -8,7 +8,7 @@ import lombok.Setter;
|
|||
public class TestPlanBugCount {
|
||||
private int index;
|
||||
private String planName;
|
||||
private long creatTime;
|
||||
private long createTime;
|
||||
private String status;
|
||||
private int caseSize;
|
||||
private int bugSize;
|
||||
|
|
|
@ -144,20 +144,22 @@ public class TrackStatisticsDTO {
|
|||
|
||||
public void countRelevance(List<TrackCountResult> relevanceResults) {
|
||||
for (TrackCountResult countResult : relevanceResults) {
|
||||
switch (countResult.getGroupField().toUpperCase()){
|
||||
switch (countResult.getGroupField()){
|
||||
case TrackCount.API:
|
||||
this.apiCaseCount += countResult.getCountNumber();
|
||||
this.allRelevanceCaseCount += countResult.getCountNumber();
|
||||
break;
|
||||
case TrackCount.PERFORMANCE:
|
||||
this.performanceCaseCount += countResult.getCountNumber();
|
||||
this.allRelevanceCaseCount += countResult.getCountNumber();
|
||||
break;
|
||||
case TrackCount.AUTOMATION:
|
||||
this.scenarioCaseCount += countResult.getCountNumber();
|
||||
this.allRelevanceCaseCount += countResult.getCountNumber();
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
this.allRelevanceCaseCount += countResult.getCountNumber();
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -12,6 +12,7 @@ import org.springframework.stereotype.Service;
|
|||
import org.springframework.transaction.annotation.Transactional;
|
||||
import javax.annotation.Resource;
|
||||
import java.math.BigDecimal;
|
||||
import java.text.DecimalFormat;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Date;
|
||||
import java.util.List;
|
||||
|
@ -110,59 +111,58 @@ public class TrackService {
|
|||
return charts;
|
||||
}
|
||||
|
||||
public BugStatustics getBugStatustics(String projectId) {
|
||||
public BugStatustics getBugStatistics(String projectId) {
|
||||
TestPlanExample example = new TestPlanExample();
|
||||
example.createCriteria().andProjectIdEqualTo(projectId);
|
||||
List<TestPlan> plans = testPlanMapper.selectByExample(example);
|
||||
List<TestPlanBugCount> list = new ArrayList<>();
|
||||
BugStatustics bugStatustics = new BugStatustics();
|
||||
int index = 1;
|
||||
int totalBugSize = 0;
|
||||
int totalCaseSize = 0;
|
||||
for (TestPlan plan : plans) {
|
||||
TestPlanBugCount testPlanBug = new TestPlanBugCount();
|
||||
testPlanBug.setIndex(index++);
|
||||
testPlanBug.setPlanName(plan.getName());
|
||||
testPlanBug.setCreatTime(plan.getCreateTime());
|
||||
testPlanBug.setCreateTime(plan.getCreateTime());
|
||||
testPlanBug.setStatus(plan.getStatus());
|
||||
testPlanBug.setCaseSize(getPlanCaseSize(plan.getId()));
|
||||
testPlanBug.setBugSize(getPlanBugSize(plan.getId()));
|
||||
testPlanBug.setPassRage(getPlanPassRage(plan.getId()));
|
||||
|
||||
int planCaseSize = getPlanCaseSize(plan.getId());
|
||||
testPlanBug.setCaseSize(planCaseSize);
|
||||
|
||||
int planBugSize = getPlanBugSize(plan.getId());
|
||||
testPlanBug.setBugSize(planBugSize);
|
||||
testPlanBug.setPassRage(getPlanPassRage(plan.getId(), planCaseSize));
|
||||
list.add(testPlanBug);
|
||||
|
||||
totalBugSize += planBugSize;
|
||||
totalCaseSize += planCaseSize;
|
||||
}
|
||||
|
||||
// todo
|
||||
bugStatustics.setList(list);
|
||||
bugStatustics.setRage("1");
|
||||
bugStatustics.setBugTotalSize(2);
|
||||
float rage =totalCaseSize == 0 ? 0 : (float) totalBugSize * 100 / totalCaseSize;
|
||||
DecimalFormat df = new DecimalFormat("0.0");
|
||||
bugStatustics.setRage(df.format(rage) + "%");
|
||||
bugStatustics.setBugTotalSize(totalBugSize);
|
||||
return bugStatustics;
|
||||
}
|
||||
|
||||
private int getPlanCaseSize(String planId) {
|
||||
TestPlanTestCaseExample testPlanTestCaseExample = new TestPlanTestCaseExample();
|
||||
testPlanTestCaseExample.createCriteria().andPlanIdEqualTo(planId);
|
||||
List<TestPlanTestCase> testPlanTestCases = testPlanTestCaseMapper.selectByExample(testPlanTestCaseExample);
|
||||
|
||||
TestPlanApiCaseExample testPlanApiCaseExample = new TestPlanApiCaseExample();
|
||||
testPlanApiCaseExample.createCriteria().andTestPlanIdEqualTo(planId);
|
||||
List<TestPlanApiCase> testPlanApiCases = testPlanApiCaseMapper.selectByExample(testPlanApiCaseExample);
|
||||
|
||||
TestPlanLoadCaseExample example = new TestPlanLoadCaseExample();
|
||||
example.createCriteria().andTestPlanIdEqualTo(planId);
|
||||
List<TestPlanLoadCase> testPlanLoadCases = testPlanLoadCaseMapper.selectByExample(example);
|
||||
|
||||
TestPlanApiScenarioExample testPlanApiScenarioExample = new TestPlanApiScenarioExample();
|
||||
testPlanApiCaseExample.createCriteria().andTestPlanIdEqualTo(planId);
|
||||
List<TestPlanApiScenario> testPlanApiScenarios = testPlanApiScenarioMapper.selectByExample(testPlanApiScenarioExample);
|
||||
|
||||
|
||||
return testPlanTestCases.size() + testPlanApiCases.size() + testPlanLoadCases.size() + testPlanApiScenarios.size();
|
||||
return extTestCaseMapper.getTestPlanCase(planId);
|
||||
|
||||
}
|
||||
|
||||
private int getPlanBugSize(String planId) {
|
||||
return 1;
|
||||
return extTestCaseMapper.getTestPlanBug(planId);
|
||||
}
|
||||
|
||||
private String getPlanPassRage(String planId) {
|
||||
return "10%";
|
||||
private String getPlanPassRage(String planId, int totalSize) {
|
||||
if (totalSize == 0) {
|
||||
return "-";
|
||||
}
|
||||
int passSize = extTestCaseMapper.getTestPlanPassCase(planId);
|
||||
float rage = (float) passSize * 100 / totalSize;
|
||||
DecimalFormat df = new DecimalFormat("0.0");
|
||||
return df.format(rage) + "%";
|
||||
}
|
||||
}
|
||||
|
|
|
@ -15,18 +15,19 @@
|
|||
{{ $t('api_test.home_page.unit_of_measurement') }}
|
||||
</span>
|
||||
<div>
|
||||
占比:
|
||||
<el-link type="info" @click="redirectPage('thisWeekCount')" target="_blank" style="color: #000000">{{ rage }}
|
||||
</el-link>
|
||||
占比
|
||||
<span class="rage">
|
||||
{{rage}}
|
||||
</span>
|
||||
</div>
|
||||
</div>
|
||||
</el-aside>
|
||||
<el-table border :data="tableData" class="adjust-table table-content" height="300">
|
||||
<el-table-column prop="index" label="序号"
|
||||
width="100" show-overflow-tooltip/>
|
||||
width="60" show-overflow-tooltip/>
|
||||
<el-table-column prop="planName" label="测试计划名称"
|
||||
width="130" show-overflow-tooltip/>
|
||||
<el-table-column prop="createTime" :label="$t('commons.create_time')" width="130">
|
||||
<el-table-column prop="createTime" :label="$t('commons.create_time')" width="180" show-overflow-tooltip>
|
||||
<template v-slot:default="scope">
|
||||
<span>{{ scope.row.createTime | timestampFormatDate }}</span>
|
||||
</template>
|
||||
|
@ -35,6 +36,7 @@
|
|||
prop="status"
|
||||
column-key="status"
|
||||
:label="$t('test_track.plan.plan_status')"
|
||||
width="100"
|
||||
show-overflow-tooltip>
|
||||
<template v-slot:default="scope">
|
||||
<span @click.stop="clickt = 'stop'">
|
||||
|
@ -106,6 +108,12 @@ export default {
|
|||
color: var(--count_number);
|
||||
}
|
||||
|
||||
.rage {
|
||||
font-family: 'ArialMT', 'Arial', sans-serif;
|
||||
font-size: 18px;
|
||||
color: var(--count_number);
|
||||
}
|
||||
|
||||
.main-number-show {
|
||||
width: 100px;
|
||||
height: 100px;
|
||||
|
|
Loading…
Reference in New Issue