From 8595a2de96d4e25161c73ed5bfc35bca7dab1e30 Mon Sep 17 00:00:00 2001 From: xiaomlove Date: Thu, 27 Oct 2022 20:31:02 +0800 Subject: [PATCH 1/2] fix: H&R limit disable user --- app/Repositories/HitAndRunRepository.php | 10 ++++++---- include/constants.php | 2 +- 2 files changed, 7 insertions(+), 5 deletions(-) diff --git a/app/Repositories/HitAndRunRepository.php b/app/Repositories/HitAndRunRepository.php index bcb6cac5..dadef83e 100644 --- a/app/Repositories/HitAndRunRepository.php +++ b/app/Repositories/HitAndRunRepository.php @@ -112,7 +112,7 @@ class HitAndRunRepository extends BaseRepository private function doCronjobUpdateStatus(array $setting, $uid = null, $torrentId = null, $ignoreTime = false) { - do_log("uid: $uid, torrentId: $torrentId, ignoreTime: " . var_export($ignoreTime, true)); + do_log("setting: " . json_encode($setting) . ", uid: $uid, torrentId: $torrentId, ignoreTime: " . var_export($ignoreTime, true)); $size = 1000; $page = 1; if (empty($setting['mode'])) { @@ -340,6 +340,7 @@ class HitAndRunRepository extends BaseRepository private function checkAndDisableUser(array $setting): void { + $logPrefix = "setting: " . json_encode($setting); $disableCounts = HitAndRun::getConfig('ban_user_when_counts_reach', $setting['search_box_id']); $query = HitAndRun::query() ->selectRaw("count(*) as counts, uid") @@ -354,13 +355,14 @@ class HitAndRunRepository extends BaseRepository } $result = $query->get(); if ($result->isEmpty()) { - do_log("No user to disable"); + do_log("$logPrefix, No user to disable: " . last_query()); return; } $users = User::query() ->with('language') ->where('enabled', User::ENABLED_YES) - ->find($result->pluck('id')->toArray(), ['id', 'username', 'lang']); + ->find($result->pluck('uid')->toArray(), ['id', 'username', 'lang']); + do_log("$logPrefix, Going to disable user: " . json_encode($users->toArray())); foreach ($users as $user) { $locale = $user->locale; $comment = nexus_trans('hr.unreached_disable_comment', [], $locale); @@ -370,7 +372,7 @@ class HitAndRunRepository extends BaseRepository 'added' => Carbon::now()->toDateTimeString(), 'subject' => $comment, 'msg' => nexus_trans('hr.unreached_disable_message_content', [ - 'ban_user_when_counts_reach' => Setting::get('hr.ban_user_when_counts_reach'), + 'ban_user_when_counts_reach' => $disableCounts, ], $locale), ]; Message::query()->insert($message); diff --git a/include/constants.php b/include/constants.php index a8d55c01..45063c5b 100644 --- a/include/constants.php +++ b/include/constants.php @@ -1,6 +1,6 @@ Date: Thu, 27 Oct 2022 20:42:15 +0800 Subject: [PATCH 2/2] H&R up limit color red --- app/Repositories/HitAndRunRepository.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/app/Repositories/HitAndRunRepository.php b/app/Repositories/HitAndRunRepository.php index dadef83e..ac61a67c 100644 --- a/app/Repositories/HitAndRunRepository.php +++ b/app/Repositories/HitAndRunRepository.php @@ -407,7 +407,7 @@ class HitAndRunRepository extends BaseRepository $out = []; foreach (SearchBox::listSections() as $key => $info) { $out[] = sprintf( - '%s: %s/%s/%s', + '%s: %s/%s/%s', $info['text'], $grouped[$info['mode']][HitAndRun::STATUS_INSPECTING] ?? 0, $grouped[$info['mode']][HitAndRun::STATUS_UNREACHED] ?? 0, @@ -423,7 +423,7 @@ class HitAndRunRepository extends BaseRepository foreach (SearchBox::listSections() as $key => $info) { if ($key == SearchBox::SECTION_BROWSE) { return sprintf( - '%s/%s/%s', + '%s/%s/%s', $grouped[HitAndRun::STATUS_INSPECTING] ?? 0, $grouped[HitAndRun::STATUS_UNREACHED] ?? 0, HitAndRun::getConfig('ban_user_when_counts_reach', $info['mode'])