Allow "Log 1st Flight" achievement to be awarded even if flight is upcoming

This commit is contained in:
2026-08-20 16:21:14 +10:00
parent 7bca9a8d31
commit 90ea8d81d2
4 changed files with 35 additions and 8 deletions
@@ -3,19 +3,35 @@
namespace App\Console\Commands;
use App\Models\User;
use Illuminate\Console\Attributes\Argument;
use Illuminate\Console\Attributes\Description;
use Illuminate\Console\Attributes\Signature;
use Illuminate\Console\Command;
#[Signature('app:recalculate-achivements')]
#[Description('Recalculate achievements for all users')]
#[Signature('app:recalculate-achievements {username? : The username of a single user to recalculate}')]
#[Description('Recalculate achievements for all users, or a single user by username')]
class RecalculateAchievements extends Command
{
public function handle(): void
{
$users = User::all();
foreach ($users as $user) {
$username = $this->argument('username');
if ($username) {
$user = User::where('name', $username)->first();
if (! $user) {
$this->error("No user found with username [{$username}].");
return;
}
$user->calculateAchievements();
$this->info("Recalculated achievements for {$username}.");
return;
}
$users = User::all();
$this->withProgressBar($users, fn (User $user) => $user->calculateAchievements());
$this->newLine();
$this->info("Recalculated achievements for {$users->count()} users.");
}
}