refactor(性能测试): 每天定时清理已经执行完成的测试中间数据
(cherry picked from commit bbbdb63b21
)
This commit is contained in:
parent
7955dc6205
commit
4f6cf0e505
|
@ -0,0 +1,37 @@
|
|||
package io.metersphere.performance.job;
|
||||
|
||||
import com.fit2cloud.quartz.anno.QuartzScheduled;
|
||||
import io.metersphere.base.domain.LoadTestReport;
|
||||
import io.metersphere.base.domain.LoadTestReportDetailExample;
|
||||
import io.metersphere.base.domain.LoadTestReportExample;
|
||||
import io.metersphere.base.mapper.LoadTestReportDetailMapper;
|
||||
import io.metersphere.base.mapper.LoadTestReportMapper;
|
||||
import io.metersphere.commons.constants.PerformanceTestStatus;
|
||||
import org.springframework.stereotype.Component;
|
||||
|
||||
import javax.annotation.Resource;
|
||||
import java.util.List;
|
||||
|
||||
@Component
|
||||
public class LoadTestReportDetailCleanJob {
|
||||
@Resource
|
||||
private LoadTestReportDetailMapper loadTestReportDetailMapper;
|
||||
@Resource
|
||||
private LoadTestReportMapper loadTestReportMapper;
|
||||
|
||||
/**
|
||||
* 每天处理一次清理任务
|
||||
*/
|
||||
@QuartzScheduled(cron = "0 0 1 * * ?")
|
||||
public void test() {
|
||||
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);
|
||||
});
|
||||
}
|
||||
}
|
Loading…
Reference in New Issue