feat(接口测试): 用例集合报告清理同步清理用例结果
This commit is contained in:
parent
6ce7f5b870
commit
91a9901533
|
@ -478,6 +478,14 @@ public class ApiScenarioReportService {
|
|||
structureExample.createCriteria().andReportIdEqualTo(request.getId());
|
||||
apiScenarioReportStructureMapper.deleteByExample(structureExample);
|
||||
|
||||
ApiDefinitionExecResultExample definitionExecResultExample = new ApiDefinitionExecResultExample();
|
||||
definitionExecResultExample.createCriteria().andIdEqualTo(request.getId());
|
||||
definitionExecResultMapper.deleteByExample(definitionExecResultExample);
|
||||
|
||||
ApiDefinitionExecResultExample execResultExample = new ApiDefinitionExecResultExample();
|
||||
execResultExample.createCriteria().andIntegratedReportIdEqualTo(request.getId());
|
||||
definitionExecResultMapper.deleteByExample(execResultExample);
|
||||
|
||||
// 补充逻辑,如果是集成报告则把零时报告全部删除
|
||||
ApiScenarioReport report = apiScenarioReportMapper.selectByPrimaryKey(request.getId());
|
||||
if (report != null && StringUtils.isNotEmpty(report.getScenarioId())) {
|
||||
|
@ -501,23 +509,42 @@ public class ApiScenarioReportService {
|
|||
ApiScenarioReportStructureExample structureExample = new ApiScenarioReportStructureExample();
|
||||
structureExample.createCriteria().andReportIdEqualTo(id);
|
||||
apiScenarioReportStructureMapper.deleteByExample(structureExample);
|
||||
|
||||
ApiDefinitionExecResultExample definitionExecResultExample = new ApiDefinitionExecResultExample();
|
||||
definitionExecResultExample.createCriteria().andIdEqualTo(id);
|
||||
definitionExecResultMapper.deleteByExample(definitionExecResultExample);
|
||||
|
||||
ApiDefinitionExecResultExample execResultExample = new ApiDefinitionExecResultExample();
|
||||
execResultExample.createCriteria().andIntegratedReportIdEqualTo(id);
|
||||
definitionExecResultMapper.deleteByExample(execResultExample);
|
||||
|
||||
}
|
||||
|
||||
public void deleteByIds(List<String> ids) {
|
||||
ApiScenarioReportExample example = new ApiScenarioReportExample();
|
||||
example.createCriteria().andIdIn(ids);
|
||||
ApiScenarioReportDetailExample detailExample = new ApiScenarioReportDetailExample();
|
||||
detailExample.createCriteria().andReportIdIn(ids);
|
||||
apiScenarioReportDetailMapper.deleteByExample(detailExample);
|
||||
apiScenarioReportMapper.deleteByExample(example);
|
||||
if (CollectionUtils.isNotEmpty(ids)) {
|
||||
ApiScenarioReportExample example = new ApiScenarioReportExample();
|
||||
example.createCriteria().andIdIn(ids);
|
||||
ApiScenarioReportDetailExample detailExample = new ApiScenarioReportDetailExample();
|
||||
detailExample.createCriteria().andReportIdIn(ids);
|
||||
apiScenarioReportDetailMapper.deleteByExample(detailExample);
|
||||
apiScenarioReportMapper.deleteByExample(example);
|
||||
|
||||
ApiScenarioReportResultExample reportResultExample = new ApiScenarioReportResultExample();
|
||||
reportResultExample.createCriteria().andReportIdIn(ids);
|
||||
apiScenarioReportResultMapper.deleteByExample(reportResultExample);
|
||||
ApiScenarioReportResultExample reportResultExample = new ApiScenarioReportResultExample();
|
||||
reportResultExample.createCriteria().andReportIdIn(ids);
|
||||
apiScenarioReportResultMapper.deleteByExample(reportResultExample);
|
||||
|
||||
ApiScenarioReportStructureExample structureExample = new ApiScenarioReportStructureExample();
|
||||
structureExample.createCriteria().andReportIdIn(ids);
|
||||
apiScenarioReportStructureMapper.deleteByExample(structureExample);
|
||||
ApiScenarioReportStructureExample structureExample = new ApiScenarioReportStructureExample();
|
||||
structureExample.createCriteria().andReportIdIn(ids);
|
||||
apiScenarioReportStructureMapper.deleteByExample(structureExample);
|
||||
|
||||
ApiDefinitionExecResultExample definitionExecResultExample = new ApiDefinitionExecResultExample();
|
||||
definitionExecResultExample.createCriteria().andIdIn(ids);
|
||||
definitionExecResultMapper.deleteByExample(definitionExecResultExample);
|
||||
|
||||
ApiDefinitionExecResultExample execResultExample = new ApiDefinitionExecResultExample();
|
||||
execResultExample.createCriteria().andIntegratedReportIdIn(ids);
|
||||
definitionExecResultMapper.deleteByExample(execResultExample);
|
||||
}
|
||||
}
|
||||
|
||||
public void deleteAPIReportBatch(APIReportBatchRequest reportRequest) {
|
||||
|
@ -571,6 +598,14 @@ public class ApiScenarioReportService {
|
|||
structureExample.createCriteria().andReportIdIn(handleIdList);
|
||||
apiScenarioReportStructureMapper.deleteByExample(structureExample);
|
||||
|
||||
ApiDefinitionExecResultExample definitionExecResultExample = new ApiDefinitionExecResultExample();
|
||||
definitionExecResultExample.createCriteria().andIdIn(handleIdList);
|
||||
definitionExecResultMapper.deleteByExample(definitionExecResultExample);
|
||||
|
||||
ApiDefinitionExecResultExample execResultExample = new ApiDefinitionExecResultExample();
|
||||
execResultExample.createCriteria().andIntegratedReportIdIn(handleIdList);
|
||||
definitionExecResultMapper.deleteByExample(execResultExample);
|
||||
|
||||
//转存剩余的数据
|
||||
ids = otherIdList;
|
||||
}
|
||||
|
@ -592,6 +627,13 @@ public class ApiScenarioReportService {
|
|||
structureExample.createCriteria().andReportIdIn(ids);
|
||||
apiScenarioReportStructureMapper.deleteByExample(structureExample);
|
||||
|
||||
ApiDefinitionExecResultExample definitionExecResultExample = new ApiDefinitionExecResultExample();
|
||||
definitionExecResultExample.createCriteria().andIdIn(ids);
|
||||
definitionExecResultMapper.deleteByExample(definitionExecResultExample);
|
||||
|
||||
ApiDefinitionExecResultExample execResultExample = new ApiDefinitionExecResultExample();
|
||||
execResultExample.createCriteria().andIntegratedReportIdIn(handleIdList);
|
||||
definitionExecResultMapper.deleteByExample(execResultExample);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -183,11 +183,36 @@
|
|||
</select>
|
||||
|
||||
<select id="idList" resultType="java.lang.String">
|
||||
SELECT r.id
|
||||
FROM api_scenario_report r
|
||||
LEFT JOIN api_scenario s on r.scenario_id = s.id
|
||||
LEFT JOIN project ON project.id = r.project_id
|
||||
LEFT JOIN user ON user.id = r.user_id
|
||||
select r.id from (
|
||||
SELECT s_r.name AS test_name,
|
||||
s_r.end_time,
|
||||
s_r.user_id,
|
||||
s_r.name,
|
||||
s_r.id,
|
||||
s_r.project_id,
|
||||
s_r.create_time,
|
||||
s_r.update_time,
|
||||
s_r.status,
|
||||
s_r.trigger_mode,
|
||||
s_r.execute_type,
|
||||
s_r.report_type
|
||||
FROM api_scenario_report s_r
|
||||
union
|
||||
select a_r.name as test_name,
|
||||
a_r.end_time,
|
||||
a_r.user_id,
|
||||
a_r.name,
|
||||
a_r.id,
|
||||
a_r.project_id,
|
||||
a_r.create_time,
|
||||
a_r.create_time as update_time,
|
||||
a_r.status,
|
||||
a_r.trigger_mode,
|
||||
'Saved' as execute_type,
|
||||
'API_INDEPENDENT' as report_type
|
||||
from api_definition_exec_result a_r
|
||||
where a_r.integrated_report_id is null
|
||||
) r
|
||||
<where>
|
||||
<if test="request.combine != null">
|
||||
<include refid="combine">
|
||||
|
@ -203,10 +228,7 @@
|
|||
AND r.user_id = #{request.userId,jdbcType=VARCHAR}
|
||||
</if>
|
||||
<if test="request.projectId != null">
|
||||
AND project.id = #{request.projectId}
|
||||
</if>
|
||||
<if test="request.workspaceId != null">
|
||||
AND project.workspace_id = #{request.workspaceId,jdbcType=VARCHAR}
|
||||
AND r.project_id = #{request.projectId}
|
||||
</if>
|
||||
<if test="request.filters != null and request.filters.size() > 0">
|
||||
<foreach collection="request.filters.entrySet()" index="key" item="values">
|
||||
|
@ -218,6 +240,12 @@
|
|||
#{value}
|
||||
</foreach>
|
||||
</when>
|
||||
<when test="key=='report_type'">
|
||||
and r.report_type in
|
||||
<foreach collection="values" item="value" separator="," open="(" close=")">
|
||||
#{value}
|
||||
</foreach>
|
||||
</when>
|
||||
<otherwise>
|
||||
and r.trigger_mode in
|
||||
<foreach collection="values" item="value" separator="," open="(" close=")">
|
||||
|
|
|
@ -315,7 +315,7 @@
|
|||
<select id="listSimple" resultType="io.metersphere.api.dto.definition.ApiTestCaseDTO">
|
||||
select
|
||||
t1.id, t1.project_id, t1.name,t1.case_status, t1.api_definition_id, t1.priority, t1.description, t1.create_user_id, t1.update_user_id, t1.create_time, t1.update_time, t1.num,
|
||||
a.module_id, a.path, a.protocol, t1.tags,t1.status,t2.STATUS AS execResult, t1.last_result_id as lastResultId, project.name as project_name,
|
||||
a.module_id, a.path, a.protocol, t1.tags,t1.status,t2.STATUS AS execResult, t2.id as lastResultId, project.name as project_name,
|
||||
t1.delete_time, deleteUser.name AS deleteUser,CONCAT(FORMAT(SUM(IF (t2.`status`='success',1,0))/COUNT(t2.id)*100,2),'%') passRate, project_version.name as version_name
|
||||
from
|
||||
api_test_case t1
|
||||
|
|
|
@ -108,9 +108,15 @@
|
|||
min-width="120px"
|
||||
:label="$t('test_track.plan_view.execute_result')">
|
||||
<template v-slot:default="scope">
|
||||
<i class="el-icon-loading ms-running" v-if="scope.row.status === 'Running'"/>
|
||||
<el-link @click="getExecResult(scope.row)"
|
||||
:class="getStatusClass(scope.row.status)">{{ getStatusTitle(scope.row.status) }}</el-link>
|
||||
<div v-if="scope.row.status === 'Running'">
|
||||
<i class="el-icon-loading ms-running"/>
|
||||
<el-link :class="getStatusClass(scope.row.status)">
|
||||
{{ getStatusTitle(scope.row.status) }}
|
||||
</el-link>
|
||||
</div>
|
||||
<el-link v-else @click="getExecResult(scope.row)" :class="getStatusClass(scope.row.execResult)">
|
||||
{{ getStatusTitle(scope.row.execResult) }}
|
||||
</el-link>
|
||||
</template>
|
||||
</ms-table-column>
|
||||
|
||||
|
@ -406,6 +412,7 @@ export default {
|
|||
statusFilters: [
|
||||
{text: this.$t('api_test.automation.success'), value: 'success'},
|
||||
{text: this.$t('api_test.automation.fail'), value: 'error'},
|
||||
{text: this.$t('report.stop_btn'), value: 'STOP'},
|
||||
{text: this.$t('api_test.home_page.detail_card.unexecute'), value: ''},
|
||||
{text: this.$t('commons.testing'), value: 'Running'}
|
||||
],
|
||||
|
@ -549,7 +556,7 @@ export default {
|
|||
this.$refs.taskCenter.openHistory(row.id);
|
||||
},
|
||||
getExecResult(apiCase) {
|
||||
if (apiCase.lastResultId) {
|
||||
if (apiCase.lastResultId && apiCase.execResult) {
|
||||
let url = "/api/definition/report/get/" + apiCase.lastResultId;
|
||||
this.$get(url, response => {
|
||||
if (response.data) {
|
||||
|
@ -560,6 +567,8 @@ export default {
|
|||
} catch (error) {
|
||||
this.resVisible = true;
|
||||
}
|
||||
} else {
|
||||
this.$warning(this.$t('commons.report_delete'));
|
||||
}
|
||||
});
|
||||
}
|
||||
|
@ -574,6 +583,8 @@ export default {
|
|||
return "ms-running";
|
||||
case "errorReportResult":
|
||||
return "ms-error-report-result";
|
||||
case "STOP":
|
||||
return "stop";
|
||||
default:
|
||||
return "ms-unexecute";
|
||||
}
|
||||
|
@ -588,6 +599,8 @@ export default {
|
|||
return this.$t('commons.testing');
|
||||
case "errorReportResult":
|
||||
return this.$t('error_report_library.option.name');
|
||||
case "STOP":
|
||||
return this.$t('report.stop_btn');
|
||||
default:
|
||||
return this.$t('api_test.home_page.detail_card.unexecute');
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue