Skip to content

Commit

Permalink
mute exception for Room::completePlay() usage
Browse files Browse the repository at this point in the history
  • Loading branch information
venix12 committed Jan 12, 2025
1 parent 086461f commit 68240dc
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 3 deletions.
2 changes: 1 addition & 1 deletion app/Console/Commands/UserSeasonScoresRecalculate.php
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ protected function recalculate(Season $season): void
->firstOrNew();

$seasonScore->season_id = $season->getKey();
$seasonScore->calculate();
$seasonScore->calculate(false);
$seasonScore->save();

$bar->advance();
Expand Down
9 changes: 7 additions & 2 deletions app/Models/UserSeasonScoreAggregate.php
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ class UserSeasonScoreAggregate extends Model
protected $primaryKey = ':composite';
protected $primaryKeys = ['user_id', 'season_id'];

public function calculate(): void
public function calculate(bool $muteExceptions = true): void
{
$rooms = $this->season->rooms()
->withPivot('group_indicator')
Expand All @@ -38,7 +38,12 @@ public function calculate(): void
$roomsGrouped = $rooms->groupBy('pivot.group_indicator');

if ($roomsGrouped->count() > count($factors)) {
throw new InvariantException(osu_trans('rankings.seasons.validation.not_enough_factors'));
// don't interrupt Room::completePlay() and throw exception only for recalculation command
if ($muteExceptions) {
return;
} else {
throw new InvariantException(osu_trans('rankings.seasons.validation.not_enough_factors'));
}
}

foreach ($roomsGrouped as $rooms) {
Expand Down

0 comments on commit 68240dc

Please sign in to comment.