refactor(测试计划): 定时清理无效队列数据

This commit is contained in:
fit2-zhao 2023-05-15 11:46:54 +08:00
parent 4fc8c840a7
commit 32f2368c9c
6 changed files with 17 additions and 2 deletions

View File

@ -533,5 +533,9 @@ public class ApiExecutionQueueService {
ApiExecutionQueueDetailExample detailExample = new ApiExecutionQueueDetailExample();
executionQueueDetailMapper.deleteByExample(detailExample);
extApiScenarioReportMapper.updateByRunning();
extApiDefinitionExecResultMapper.updateByRunning();
}
}

View File

@ -53,4 +53,6 @@ public interface ExtApiDefinitionExecResultMapper {
List<String> selectDistinctStatusByReportId(String reportId);
List<String> selectByProjectIdAndLessThanTime(@Param("projectId") String projectId, @Param("time") long time);
void updateByRunning();
}

View File

@ -484,4 +484,8 @@
select id from api_definition_exec_result where project_id = #{projectId} and create_time &lt; #{time}
</select>
<update id="updateByRunning" parameterType="java.util.List">
update api_definition_exec_result set `status`= "STOP" where `status` ="Running"
</update>
</mapper>

View File

@ -11,8 +11,7 @@
FROM
api_execution_queue
WHERE
report_id != NULL
AND run_mode IN ( 'API_PLAN', 'JENKINS_SCENARIO_PLAN', 'SCHEDULE_SCENARIO_PLAN' )
run_mode IN ( 'API_PLAN', 'JENKINS_SCENARIO_PLAN', 'SCHEDULE_SCENARIO_PLAN' )
AND id NOT IN ( SELECT t1.queue_id FROM api_execution_queue_detail t1 )
AND report_id NOT IN ( SELECT report_id FROM test_plan_execution_queue );
</select>

View File

@ -48,4 +48,6 @@ public interface ExtApiScenarioReportMapper {
List<ApiScenarioReport> findByProjectIds(@Param("request") TaskCenterRequest request);
List<String> selectByProjectIdAndLessThanTime(@Param("projectId") String projectId, @Param("time") long time);
void updateByRunning();
}

View File

@ -468,4 +468,8 @@
select id from api_scenario_report where create_time &lt; #{time} and project_id = #{projectId}
</select>
<update id="updateByRunning">
update api_scenario_report set `status`= "STOP" where `status` ="Running"
</update>
</mapper>