改进 主机错误删除任务

This commit is contained in:
iVampireSP.com 2023-03-04 18:33:07 +08:00
parent 86c0d3db5b
commit b4482da0f0
No known key found for this signature in database
GPG Key ID: 2F7B001CA27A8132

View File

@ -36,6 +36,13 @@ public function handle(): void
// 查找不可用时间超过 3 天以上的 host
(new Host)->where('status', 'unavailable')->where('unavailable_at', '<', now()->subDays(3))->delete();
// 查找错误状态超过 7 天以上的 host
(new Host)->where('status', 'error')->where('updated_at', '<', now()->subDays(7))->chunk(100, function ($hosts) {
foreach ($hosts as $host) {
dispatch(new HostJob($host, 'delete'));
}
});
// 查找锁定时间超过 3 天以上的 host
// (new Host)->where('status', 'locked')->where('locked_at', '<', now()->subDays(3))->chunk(100, function ($hosts) {
// foreach ($hosts as $host) {