Skip to content

Commit 5d06cc5

Browse files
authored
Merge pull request #4428 from Roardom/fix-autogroup
(Fix) Autogroup enabling dl rights when a user has active warnings
2 parents 4b212d0 + be3582a commit 5d06cc5

File tree

1 file changed

+5
-2
lines changed

1 file changed

+5
-2
lines changed

Diff for: app/Console/Commands/AutoGroup.php

+5-2
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,10 @@ final public function handle(): void
5757

5858
User::query()
5959
->withSum('seedingTorrents as seedsize', 'size')
60-
->withCount('torrents as uploads')
60+
->withCount([
61+
'torrents as uploads',
62+
'warnings' => fn ($query) => $query->where('active', '=', true),
63+
])
6164
->withAvg('history as avg_seedtime', 'seedtime')
6265
->whereIntegerInRaw('group_id', $groups->pluck('id'))
6366
->chunkById(100, function ($users) use ($groups, $timestamp): void {
@@ -78,7 +81,7 @@ final public function handle(): void
7881
// Keep these as 0/1 instead of false/true
7982
// because it reduces 6% custom casting overhead
8083
$user->can_download = 0;
81-
} else {
84+
} elseif ($user->warnings_count < config('hitrun.max_warnings')) {
8285
$user->can_download = 1;
8386
}
8487

0 commit comments

Comments
 (0)