the browser-facing portion of osu!
at master 1.5 kB view raw
1<?php 2 3// Copyright (c) ppy Pty Ltd <contact@ppy.sh>. Licensed under the GNU Affero General Public License v3.0. 4// See the LICENCE file in the repository root for full licence text. 5 6declare(strict_types=1); 7 8namespace App\Console\Commands; 9 10use App\Models\Beatmap; 11use App\Models\BeatmapLeader; 12use Illuminate\Console\Command; 13use Illuminate\Database\Eloquent\Collection; 14 15class BeatmapLeadersRefresh extends Command 16{ 17 /** 18 * The name and signature of the console command. 19 * 20 * @var string 21 */ 22 protected $signature = 'beatmap-leaders:refresh'; 23 24 /** 25 * The console command description. 26 * 27 * @var string 28 */ 29 protected $description = 'Refresh beatmap leaders table'; 30 31 /** 32 * Execute the console command. 33 * 34 * @return mixed 35 */ 36 public function handle() 37 { 38 $continue = $this->option('no-interaction') || $this->confirm('This will recalculate beatmap leaders, continue?', true); 39 40 if (!$continue) { 41 return $this->error('User aborted!'); 42 } 43 44 $bar = $this->output->createProgressBar(); 45 46 Beatmap::select('beatmap_id')->scoreable()->chunkById(100, function (Collection $beatmaps) use ($bar): void { 47 foreach ($beatmaps as $beatmap) { 48 foreach (Beatmap::MODES as $ruleset => $rulesetId) { 49 BeatmapLeader::sync($beatmap->getKey(), $rulesetId); 50 $bar->advance(); 51 } 52 } 53 }); 54 $bar->finish(); 55 $this->line(''); 56 } 57}