Skip to content

Commit

Permalink
fix: autogroup enabling dl rights when a user has active warnings
Browse files Browse the repository at this point in the history
  • Loading branch information
Roardom committed Jan 16, 2025
1 parent dbade37 commit be3582a
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 be3582a

Please sign in to comment.