From 28b85c7ecf290191223d12bbebffed550be11fd3 Mon Sep 17 00:00:00 2001 From: xiaomlove Date: Sat, 1 Oct 2022 01:58:18 +0800 Subject: [PATCH] judge H&R count think about section --- app/Console/Commands/HitAndRunUpdateStatus.php | 4 ++-- app/Console/Commands/Test.php | 6 ++++-- app/Filament/Resources/User/HitAndRunResource.php | 2 +- app/Repositories/HitAndRunRepository.php | 7 ++++++- include/globalfunctions.php | 2 +- 5 files changed, 14 insertions(+), 7 deletions(-) diff --git a/app/Console/Commands/HitAndRunUpdateStatus.php b/app/Console/Commands/HitAndRunUpdateStatus.php index b0f09ecc..7ca934c0 100644 --- a/app/Console/Commands/HitAndRunUpdateStatus.php +++ b/app/Console/Commands/HitAndRunUpdateStatus.php @@ -44,8 +44,8 @@ class HitAndRunUpdateStatus extends Command $rep = new HitAndRunRepository(); $result = $rep->cronjobUpdateStatus($uid, $torrentId, $ignoreTime); $log = sprintf( - '[%s], %s, uid: %s, torrentId: %s, result: %s', - nexus()->getRequestId(), __METHOD__, $uid, $torrentId, var_export($result, true) + '[%s], %s, uid: %s, torrentId: %s, ignoreTime: %s, result: %s', + nexus()->getRequestId(), __METHOD__, $uid, $torrentId, $ignoreTime, var_export($result, true) ); $this->info($log); do_log($log); diff --git a/app/Console/Commands/Test.php b/app/Console/Commands/Test.php index 13b3ba74..aebb3808 100644 --- a/app/Console/Commands/Test.php +++ b/app/Console/Commands/Test.php @@ -89,8 +89,10 @@ class Test extends Command */ public function handle() { - $r = strstr('hr.*', '.', true); - dd($r); + $rep = new \NexusPlugin\HitAndRun\HitAndRunRepository(); + $rep->initSectionHitAndRunSetting(SearchBox::SECTION_BROWSE . "_"); + $rep->initSectionHitAndRunSetting(SearchBox::SECTION_SPECIAL . "_"); + clear_setting_cache(); } diff --git a/app/Filament/Resources/User/HitAndRunResource.php b/app/Filament/Resources/User/HitAndRunResource.php index 17d4e132..654df0cb 100644 --- a/app/Filament/Resources/User/HitAndRunResource.php +++ b/app/Filament/Resources/User/HitAndRunResource.php @@ -72,7 +72,7 @@ class HitAndRunResource extends Resource public static function getEloquentQuery(): Builder { - return parent::getEloquentQuery()->with(['user', 'torrent', 'snatch']); + return parent::getEloquentQuery()->with(['user', 'torrent', 'snatch', 'torrent.basic_category']); } public static function getRelations(): array diff --git a/app/Repositories/HitAndRunRepository.php b/app/Repositories/HitAndRunRepository.php index 2c20f091..c1faa836 100644 --- a/app/Repositories/HitAndRunRepository.php +++ b/app/Repositories/HitAndRunRepository.php @@ -335,7 +335,12 @@ class HitAndRunRepository extends BaseRepository //disable user /** @var User $user */ $user = $hitAndRun->user; - $counts = $user->hitAndRuns()->where('status', HitAndRun::STATUS_UNREACHED)->count(); + $counts = $user->hitAndRuns() + ->where('status', HitAndRun::STATUS_UNREACHED) + ->whereHas('torrent.basic_category', function (Builder $query) use ($searchBoxId) { + return $query->where('mode', $searchBoxId); + }) + ->count(); $disableCounts = HitAndRun::getConfig('ban_user_when_counts_reach', $searchBoxId); do_log("user: {$user->id}, H&R counts: $counts, disableCounts: $disableCounts", 'notice'); if ($counts >= $disableCounts) { diff --git a/include/globalfunctions.php b/include/globalfunctions.php index 09b50ebf..5534c4a2 100644 --- a/include/globalfunctions.php +++ b/include/globalfunctions.php @@ -971,7 +971,7 @@ function clear_user_cache($uid, $passkey = '') } } -function clear_setting_cache($buildPermissionCache = false) +function clear_setting_cache() { \Nexus\Database\NexusDB::cache_del('nexus_settings_in_laravel'); \Nexus\Database\NexusDB::cache_del('nexus_settings_in_nexus');