From be3582afe9af7663ff7868be52b7463aa5606f3d Mon Sep 17 00:00:00 2001 From: Roardom Date: Wed, 15 Jan 2025 00:58:29 +0000 Subject: [PATCH] fix: autogroup enabling dl rights when a user has active warnings --- app/Console/Commands/AutoGroup.php | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/app/Console/Commands/AutoGroup.php b/app/Console/Commands/AutoGroup.php index 553628ac35..2458d1ed15 100644 --- a/app/Console/Commands/AutoGroup.php +++ b/app/Console/Commands/AutoGroup.php @@ -57,7 +57,10 @@ final public function handle(): void User::query() ->withSum('seedingTorrents as seedsize', 'size') - ->withCount('torrents as uploads') + ->withCount([ + 'torrents as uploads', + 'warnings' => fn ($query) => $query->where('active', '=', true), + ]) ->withAvg('history as avg_seedtime', 'seedtime') ->whereIntegerInRaw('group_id', $groups->pluck('id')) ->chunkById(100, function ($users) use ($groups, $timestamp): void { @@ -78,7 +81,7 @@ final public function handle(): void // Keep these as 0/1 instead of false/true // because it reduces 6% custom casting overhead $user->can_download = 0; - } else { + } elseif ($user->warnings_count < config('hitrun.max_warnings')) { $user->can_download = 1; }