Skip to content

Commit

Permalink
Merge pull request #4428 from Roardom/fix-autogroup
Browse files Browse the repository at this point in the history
(Fix) Autogroup enabling dl rights when a user has active warnings
  • Loading branch information
HDVinnie authored Jan 20, 2025
2 parents 4b212d0 + be3582a commit 5d06cc5
Showing 1 changed file with 5 additions and 2 deletions.
7 changes: 5 additions & 2 deletions app/Console/Commands/AutoGroup.php
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand All @@ -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;
}

Expand Down

0 comments on commit 5d06cc5

Please sign in to comment.