fix: 删除性能测试报告依然统计 (#5698)

Co-authored-by: chenjianxing <jianxing.chen@fit2cloud.com>
This commit is contained in:
metersphere-bot 2021-08-25 21:31:15 +08:00 committed by GitHub
parent 7d4f112728
commit dc6c8904cb
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 16 additions and 1 deletions

View File

@ -176,7 +176,9 @@
select status from test_plan_load_case tplc where tplc.test_plan_id = #{planId}
</select>
<select id="selectForPlanReport" resultType="io.metersphere.track.dto.PlanReportCaseDTO">
select id,status from test_plan_load_case where test_plan_id = #{planId};
select tplc.id,tplc.status from test_plan_load_case tplc
inner join load_test lt on tplc.load_case_id = lt.id
where tplc.test_plan_id = #{planId};
</select>
<select id="getCases" resultType="io.metersphere.track.dto.TestPlanLoadCaseDTO">
select tplc.id, lt.id as caseId, lt.name, lt.num, lt.project_id,

View File

@ -40,12 +40,14 @@ import io.metersphere.service.FileService;
import io.metersphere.service.QuotaService;
import io.metersphere.service.ScheduleService;
import io.metersphere.track.service.TestCaseService;
import io.metersphere.track.service.TestPlanLoadCaseService;
import org.apache.commons.collections4.ListUtils;
import org.apache.commons.lang3.StringUtils;
import org.apache.ibatis.session.ExecutorType;
import org.apache.ibatis.session.SqlSession;
import org.apache.ibatis.session.SqlSessionFactory;
import org.aspectj.util.FileUtil;
import org.springframework.context.annotation.Lazy;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import org.springframework.util.CollectionUtils;
@ -104,6 +106,9 @@ public class PerformanceTestService {
private SqlSessionFactory sqlSessionFactory;
@Resource
private ApiPerformanceService apiPerformanceService;
@Lazy
@Resource
private TestPlanLoadCaseService testPlanLoadCaseService;
public List<LoadTestDTO> list(QueryTestPlanRequest request) {
request.setOrders(ServiceUtils.getDefaultOrder(request.getOrders()));
@ -135,6 +140,8 @@ public class PerformanceTestService {
// delete load_test
loadTestMapper.deleteByPrimaryKey(request.getId());
testPlanLoadCaseService.deleteByTestId(testId);
detachFileByTestId(request.getId());
}

View File

@ -124,6 +124,12 @@ public class TestPlanLoadCaseService {
testPlanLoadCaseMapper.deleteByExample(testPlanLoadCaseExample);
}
public void deleteByTestId(String testId) {
TestPlanLoadCaseExample testPlanLoadCaseExample = new TestPlanLoadCaseExample();
testPlanLoadCaseExample.createCriteria().andLoadCaseIdEqualTo(testId);
testPlanLoadCaseMapper.deleteByExample(testPlanLoadCaseExample);
}
public String run(RunTestPlanRequest request) {
String reportId = performanceTestService.run(request);
TestPlanLoadCase testPlanLoadCase = new TestPlanLoadCase();