refactor(性能测试): 每天定时清理已经执行完成的测试中间数据
This commit is contained in:
parent
aadf243399
commit
592b2a7cd0
|
@ -1,6 +1,7 @@
|
|||
package io.metersphere.performance.job;
|
||||
|
||||
import com.fit2cloud.quartz.anno.QuartzScheduled;
|
||||
import com.github.pagehelper.PageHelper;
|
||||
import io.metersphere.base.domain.LoadTestReport;
|
||||
import io.metersphere.base.domain.LoadTestReportDetailExample;
|
||||
import io.metersphere.base.domain.LoadTestReportExample;
|
||||
|
@ -26,12 +27,16 @@ public class LoadTestReportDetailCleanJob {
|
|||
public void cleanCompletedTestDetail() {
|
||||
LoadTestReportExample example = new LoadTestReportExample();
|
||||
example.createCriteria().andStatusEqualTo(PerformanceTestStatus.Completed.name());
|
||||
List<LoadTestReport> loadTestReports = loadTestReportMapper.selectByExample(example);
|
||||
loadTestReports.forEach(report -> {
|
||||
// 清理文件
|
||||
LoadTestReportDetailExample example2 = new LoadTestReportDetailExample();
|
||||
example2.createCriteria().andReportIdEqualTo(report.getId());
|
||||
loadTestReportDetailMapper.deleteByExample(example2);
|
||||
});
|
||||
long count = loadTestReportMapper.countByExample(example);
|
||||
for (int i = 0; i < count / 10; i++) {
|
||||
PageHelper.startPage(i, 10);
|
||||
List<LoadTestReport> loadTestReports = loadTestReportMapper.selectByExample(example);
|
||||
loadTestReports.forEach(report -> {
|
||||
// 清理文件
|
||||
LoadTestReportDetailExample example2 = new LoadTestReportDetailExample();
|
||||
example2.createCriteria().andReportIdEqualTo(report.getId());
|
||||
loadTestReportDetailMapper.deleteByExample(example2);
|
||||
});
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue