From d393d83379de4ebfc958baf5c83def146c3c8842 Mon Sep 17 00:00:00 2001 From: lgb <353856593@qq.com> Date: Mon, 24 Jul 2023 21:44:22 +0800 Subject: [PATCH] fix Cleanup runBatchJob --- app/Repositories/CleanupRepository.php | 22 ++++++++++------------ include/constants.php | 2 +- 2 files changed, 11 insertions(+), 13 deletions(-) diff --git a/app/Repositories/CleanupRepository.php b/app/Repositories/CleanupRepository.php index 02f0daebe..30d011dbd 100644 --- a/app/Repositories/CleanupRepository.php +++ b/app/Repositories/CleanupRepository.php @@ -88,18 +88,16 @@ private static function runBatchJob($batchKey, $requestId) /* Don't ever return an empty array until we're done iterating */ $redis->setOption(\Redis::OPT_SCAN, \Redis::SCAN_RETRY); while($arr_keys = $redis->hScan($batch, $it, "*", self::$scanSize)) { - foreach($arr_keys as $k => $v) { - $delay = self::getDelay($batchKeyInfo['task_index'], $length, $page); - $idStr = implode(",", array_keys($arr_keys)); - $command = sprintf( - 'cleanup --action=%s --begin_id=%s --end_id=%s --id_str=%s --request_id=%s --delay=%s', - $batchKeyInfo['action'], 0, 0, $idStr, $requestId, $delay - ); - $output = executeCommand($command, 'string', true); - do_log(sprintf('command: %s, output: %s', $command, $output)); - $page++; - $count += count($arr_keys); - } + $delay = self::getDelay($batchKeyInfo['task_index'], $length, $page); + $idStr = implode(",", array_keys($arr_keys)); + $command = sprintf( + 'cleanup --action=%s --begin_id=%s --end_id=%s --id_str=%s --request_id=%s --delay=%s', + $batchKeyInfo['action'], 0, 0, $idStr, $requestId, $delay + ); + $output = executeCommand($command, 'string', true); + do_log(sprintf('command: %s, output: %s', $command, $output)); + $count += count($arr_keys); + $page++; } //remove this batch diff --git a/include/constants.php b/include/constants.php index fc7db3371..1991000f7 100644 --- a/include/constants.php +++ b/include/constants.php @@ -1,6 +1,6 @@