refactor: 优化删除场景报告效率
--bug=1012162 --user=陈建星 【UI测试】删除UI报告用时40多秒 https://www.tapd.cn/55049933/s/1135495
This commit is contained in:
parent
475e935fd5
commit
3c8abbdc58
|
@ -31,4 +31,6 @@ public class DeleteAPIReportRequest {
|
||||||
private List<String> moduleIds;
|
private List<String> moduleIds;
|
||||||
|
|
||||||
private List<String> unSelectIds;
|
private List<String> unSelectIds;
|
||||||
|
|
||||||
|
private Boolean isUi;
|
||||||
}
|
}
|
||||||
|
|
|
@ -30,6 +30,7 @@ import io.metersphere.track.dto.PlanReportCaseDTO;
|
||||||
import io.metersphere.utils.LoggerUtil;
|
import io.metersphere.utils.LoggerUtil;
|
||||||
import org.apache.commons.beanutils.BeanMap;
|
import org.apache.commons.beanutils.BeanMap;
|
||||||
import org.apache.commons.collections4.CollectionUtils;
|
import org.apache.commons.collections4.CollectionUtils;
|
||||||
|
import org.apache.commons.lang3.BooleanUtils;
|
||||||
import org.apache.commons.lang3.StringUtils;
|
import org.apache.commons.lang3.StringUtils;
|
||||||
import org.slf4j.Logger;
|
import org.slf4j.Logger;
|
||||||
import org.slf4j.LoggerFactory;
|
import org.slf4j.LoggerFactory;
|
||||||
|
@ -549,6 +550,7 @@ public class ApiScenarioReportService {
|
||||||
structureExample.createCriteria().andReportIdEqualTo(request.getId());
|
structureExample.createCriteria().andReportIdEqualTo(request.getId());
|
||||||
apiScenarioReportStructureMapper.deleteByExample(structureExample);
|
apiScenarioReportStructureMapper.deleteByExample(structureExample);
|
||||||
|
|
||||||
|
if (BooleanUtils.isNotTrue(request.getIsUi())) {
|
||||||
ApiDefinitionExecResultExample definitionExecResultExample = new ApiDefinitionExecResultExample();
|
ApiDefinitionExecResultExample definitionExecResultExample = new ApiDefinitionExecResultExample();
|
||||||
definitionExecResultExample.createCriteria().andIdEqualTo(request.getId());
|
definitionExecResultExample.createCriteria().andIdEqualTo(request.getId());
|
||||||
definitionExecResultMapper.deleteByExample(definitionExecResultExample);
|
definitionExecResultMapper.deleteByExample(definitionExecResultExample);
|
||||||
|
@ -556,6 +558,7 @@ public class ApiScenarioReportService {
|
||||||
ApiDefinitionExecResultExample execResultExample = new ApiDefinitionExecResultExample();
|
ApiDefinitionExecResultExample execResultExample = new ApiDefinitionExecResultExample();
|
||||||
execResultExample.createCriteria().andIntegratedReportIdEqualTo(request.getId());
|
execResultExample.createCriteria().andIntegratedReportIdEqualTo(request.getId());
|
||||||
definitionExecResultMapper.deleteByExample(execResultExample);
|
definitionExecResultMapper.deleteByExample(execResultExample);
|
||||||
|
}
|
||||||
|
|
||||||
// 补充逻辑,如果是集成报告则把零时报告全部删除
|
// 补充逻辑,如果是集成报告则把零时报告全部删除
|
||||||
ApiScenarioReport report = apiScenarioReportMapper.selectByPrimaryKey(request.getId());
|
ApiScenarioReport report = apiScenarioReportMapper.selectByPrimaryKey(request.getId());
|
||||||
|
@ -563,6 +566,7 @@ public class ApiScenarioReportService {
|
||||||
List<String> list = getReportIds(report.getScenarioId());
|
List<String> list = getReportIds(report.getScenarioId());
|
||||||
if (CollectionUtils.isNotEmpty(list)) {
|
if (CollectionUtils.isNotEmpty(list)) {
|
||||||
APIReportBatchRequest reportRequest = new APIReportBatchRequest();
|
APIReportBatchRequest reportRequest = new APIReportBatchRequest();
|
||||||
|
reportRequest.setIsUi(request.getIsUi());
|
||||||
reportRequest.setIds(list);
|
reportRequest.setIds(list);
|
||||||
this.deleteAPIReportBatch(reportRequest);
|
this.deleteAPIReportBatch(reportRequest);
|
||||||
}
|
}
|
||||||
|
@ -669,6 +673,7 @@ public class ApiScenarioReportService {
|
||||||
structureExample.createCriteria().andReportIdIn(handleIdList);
|
structureExample.createCriteria().andReportIdIn(handleIdList);
|
||||||
apiScenarioReportStructureMapper.deleteByExample(structureExample);
|
apiScenarioReportStructureMapper.deleteByExample(structureExample);
|
||||||
|
|
||||||
|
if (BooleanUtils.isNotTrue(reportRequest.getIsUi())) {
|
||||||
ApiDefinitionExecResultExample definitionExecResultExample = new ApiDefinitionExecResultExample();
|
ApiDefinitionExecResultExample definitionExecResultExample = new ApiDefinitionExecResultExample();
|
||||||
definitionExecResultExample.createCriteria().andIdIn(handleIdList);
|
definitionExecResultExample.createCriteria().andIdIn(handleIdList);
|
||||||
definitionExecResultMapper.deleteByExample(definitionExecResultExample);
|
definitionExecResultMapper.deleteByExample(definitionExecResultExample);
|
||||||
|
@ -676,6 +681,7 @@ public class ApiScenarioReportService {
|
||||||
ApiDefinitionExecResultExample execResultExample = new ApiDefinitionExecResultExample();
|
ApiDefinitionExecResultExample execResultExample = new ApiDefinitionExecResultExample();
|
||||||
execResultExample.createCriteria().andIntegratedReportIdIn(handleIdList);
|
execResultExample.createCriteria().andIntegratedReportIdIn(handleIdList);
|
||||||
definitionExecResultMapper.deleteByExample(execResultExample);
|
definitionExecResultMapper.deleteByExample(execResultExample);
|
||||||
|
}
|
||||||
|
|
||||||
//转存剩余的数据
|
//转存剩余的数据
|
||||||
ids = otherIdList;
|
ids = otherIdList;
|
||||||
|
@ -698,6 +704,7 @@ public class ApiScenarioReportService {
|
||||||
structureExample.createCriteria().andReportIdIn(ids);
|
structureExample.createCriteria().andReportIdIn(ids);
|
||||||
apiScenarioReportStructureMapper.deleteByExample(structureExample);
|
apiScenarioReportStructureMapper.deleteByExample(structureExample);
|
||||||
|
|
||||||
|
if (BooleanUtils.isNotTrue(reportRequest.getIsUi())) {
|
||||||
ApiDefinitionExecResultExample definitionExecResultExample = new ApiDefinitionExecResultExample();
|
ApiDefinitionExecResultExample definitionExecResultExample = new ApiDefinitionExecResultExample();
|
||||||
definitionExecResultExample.createCriteria().andIdIn(ids);
|
definitionExecResultExample.createCriteria().andIdIn(ids);
|
||||||
definitionExecResultMapper.deleteByExample(definitionExecResultExample);
|
definitionExecResultMapper.deleteByExample(definitionExecResultExample);
|
||||||
|
@ -707,6 +714,7 @@ public class ApiScenarioReportService {
|
||||||
definitionExecResultMapper.deleteByExample(execResultExample);
|
definitionExecResultMapper.deleteByExample(execResultExample);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
public long countByProjectIdAndCreateAndByScheduleInThisWeek(String projectId) {
|
public long countByProjectIdAndCreateAndByScheduleInThisWeek(String projectId) {
|
||||||
Map<String, Date> startAndEndDateInWeek = DateUtils.getWeedFirstTimeAndLastTime(new Date());
|
Map<String, Date> startAndEndDateInWeek = DateUtils.getWeedFirstTimeAndLastTime(new Date());
|
||||||
|
|
|
@ -231,3 +231,6 @@ VALUES (UUID(), 'ws_admin', 'WORKSPACE_QUOTA:READ+EDIT', 'WORKSPACE_QUOTA');
|
||||||
|
|
||||||
-- 删除场景冗余字段
|
-- 删除场景冗余字段
|
||||||
ALTER TABLE api_scenario DROP COLUMN use_url;
|
ALTER TABLE api_scenario DROP COLUMN use_url;
|
||||||
|
|
||||||
|
-- 优化删除报告效率
|
||||||
|
CREATE INDEX api_definition_exec_result_integrated_report_id_IDX USING BTREE ON api_definition_exec_result (integrated_report_id);
|
||||||
|
|
|
@ -324,7 +324,7 @@ export default {
|
||||||
confirmButtonText: this.$t('commons.confirm'),
|
confirmButtonText: this.$t('commons.confirm'),
|
||||||
callback: (action) => {
|
callback: (action) => {
|
||||||
if (action === 'confirm') {
|
if (action === 'confirm') {
|
||||||
this.result = this.$post("/api/scenario/report/delete", {id: report.id}, () => {
|
this.result = this.$post("/api/scenario/report/delete", {id: report.id, isUi: this.isUI}, () => {
|
||||||
this.$success(this.$t('commons.delete_success'));
|
this.$success(this.$t('commons.delete_success'));
|
||||||
this.search();
|
this.search();
|
||||||
});
|
});
|
||||||
|
|
Loading…
Reference in New Issue