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(); ApiExecutionQueueDetailExample detailExample = new ApiExecutionQueueDetailExample();
executionQueueDetailMapper.deleteByExample(detailExample); executionQueueDetailMapper.deleteByExample(detailExample);
extApiScenarioReportMapper.updateByRunning();
extApiDefinitionExecResultMapper.updateByRunning();
} }
} }

View File

@ -53,4 +53,6 @@ public interface ExtApiDefinitionExecResultMapper {
List<String> selectDistinctStatusByReportId(String reportId); List<String> selectDistinctStatusByReportId(String reportId);
List<String> selectByProjectIdAndLessThanTime(@Param("projectId") String projectId, @Param("time") long time); 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 id from api_definition_exec_result where project_id = #{projectId} and create_time &lt; #{time}
</select> </select>
<update id="updateByRunning" parameterType="java.util.List">
update api_definition_exec_result set `status`= "STOP" where `status` ="Running"
</update>
</mapper> </mapper>

View File

@ -11,8 +11,7 @@
FROM FROM
api_execution_queue api_execution_queue
WHERE WHERE
report_id != NULL run_mode IN ( 'API_PLAN', 'JENKINS_SCENARIO_PLAN', 'SCHEDULE_SCENARIO_PLAN' )
AND 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 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 ); AND report_id NOT IN ( SELECT report_id FROM test_plan_execution_queue );
</select> </select>

View File

@ -48,4 +48,6 @@ public interface ExtApiScenarioReportMapper {
List<ApiScenarioReport> findByProjectIds(@Param("request") TaskCenterRequest request); List<ApiScenarioReport> findByProjectIds(@Param("request") TaskCenterRequest request);
List<String> selectByProjectIdAndLessThanTime(@Param("projectId") String projectId, @Param("time") long time); 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 id from api_scenario_report where create_time &lt; #{time} and project_id = #{projectId}
</select> </select>
<update id="updateByRunning">
update api_scenario_report set `status`= "STOP" where `status` ="Running"
</update>
</mapper> </mapper>