改进 删除

This commit is contained in:
iVampireSP.com 2023-03-02 19:34:01 +08:00
parent 327006e337
commit e2ead8de63
No known key found for this signature in database
GPG Key ID: 2F7B001CA27A8132

View File

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