集計一覧
+id | +max | +updated_at | +
---|---|---|
{{$value->id}} | +{{$value->max}} | +{{$value->updated_at}} | +
diff --git a/OngekiScoreLog/app/AggregateOverdamage.php b/OngekiScoreLog/app/AggregateOverdamage.php new file mode 100644 index 00000000..b3a59910 --- /dev/null +++ b/OngekiScoreLog/app/AggregateOverdamage.php @@ -0,0 +1,61 @@ +basic_level !== null){ + foreach ($normalDifficulties as $difficulty) { + \App\AggregateOverdamage::record($music->id, $difficulty); + } + } + + if($music->lunatic_level !== null){ + \App\AggregateOverdamage::record($music->id, $lunaticDifficulty); + } + } + + \App\Facades\Slack::Debug("Max Over Damageの集計を行いました。"); + } + + public static function record($song_id, $difficulty){ + $max = AggregateOverdamage::calculation($song_id, $difficulty); + + $key = $song_id . "_" . $difficulty; + AggregateOverdamage::updateOrCreate( + ['id' => $key], + ['song_id' => $song_id, 'difficulty' => $difficulty, 'max' => $max] + ); + } + + private static function calculation($song_id, $difficulty){ + $sql = DB::table('score_datas') + ->select('song_id', 'difficulty', DB::raw('MAX(over_damage_high_score) as max_over_damage_high_score')) + ->where('song_id', $song_id) + ->where('difficulty', $difficulty) + ->groupBy('song_id', 'difficulty') + ; + try { + return $sql->get()[0]->max_over_damage_high_score; + } catch (\Throwable $th) { + return 0; + } + } +} diff --git a/OngekiScoreLog/app/Console/Kernel.php b/OngekiScoreLog/app/Console/Kernel.php index 1f18e1ad..48d3f587 100644 --- a/OngekiScoreLog/app/Console/Kernel.php +++ b/OngekiScoreLog/app/Console/Kernel.php @@ -30,7 +30,12 @@ protected function schedule(Schedule $schedule) $schedule->call(function () { \App\UserInformation::ResetAllUserPaymentState(); \App\Facades\Slack::Info(" すべてのユーザーの課金情報をリセットしました。"); - })->monthlyOn(1, '4:00'); + })->monthlyOn(1, '7:00'); + + // Max OverDamageの集計 + $schedule->call(function () { + \App\AggregateOverdamage::execute(); + })->dailyAt('4:30'); } /** diff --git a/OngekiScoreLog/app/Http/Controllers/AdminController.php b/OngekiScoreLog/app/Http/Controllers/AdminController.php index 5f718b7e..c9b095a5 100644 --- a/OngekiScoreLog/app/Http/Controllers/AdminController.php +++ b/OngekiScoreLog/app/Http/Controllers/AdminController.php @@ -69,6 +69,11 @@ public function GetConfig(){ return view('admin/config', compact(['result'])); } + public function GetAggregate(){ + $result = \App\AggregateOverdamage::all(); + return view('admin/aggregate', compact(['result'])); + } + /** * '/config'にgetリクエストがあったときに呼び出されます。 * パラメータに合致する処理を行い、'/'にリダイレクトします。 @@ -124,4 +129,10 @@ public function GetApply($type, $action = null){ return redirect('/admin?message=' . $message); } + + public function GetGenerateOverDamage(){ + ini_set("max_execution_time", 0); + \App\AggregateOverdamage::execute(); + return redirect('/admin?message=' . "Generate Over Damage: max. 実行しました!"); + } } diff --git a/OngekiScoreLog/app/Http/Controllers/ViewUserController.php b/OngekiScoreLog/app/Http/Controllers/ViewUserController.php index 0f8bf200..d9d2e68b 100644 --- a/OngekiScoreLog/app/Http/Controllers/ViewUserController.php +++ b/OngekiScoreLog/app/Http/Controllers/ViewUserController.php @@ -8,7 +8,10 @@ use App\User; use App\UserStatus; use App\ScoreData; +use App\AggregateOverdamage; use App\Facades\OngekiUtility; +use DateTime; + use function GuzzleHttp\json_encode; class ViewUserController extends Controller @@ -386,13 +389,17 @@ public function getOverDamegePage($id){ } // トップランカーのスコアを取得してkey: song_id, difficulty, value: over_damage_high_score の配列を作る + $lastUpdate = (new DateTime())->setTimestamp(0); $topRankerScore = []; { - $temp = (new ScoreData)->getTopRankerScore()->getValue(); + $temp = AggregateOverdamage::all(); foreach ($temp as $value) { $key = $value->song_id . "_" . $value->difficulty; - if(!isset($topRankerScore[$key])){ - $topRankerScore[$key] = $value->max_over_damage_high_score; + $topRankerScore[$key] = $value->max; + + // 最終更新日時を取得 + if($lastUpdate < $value->updated_at){ + $lastUpdate = $value->updated_at; } } } @@ -422,6 +429,6 @@ public function getOverDamegePage($id){ } } - return view('user_overdamage', compact('id', 'status', 'scoreDatas', 'topRankerScore')); + return view('user_overdamage', compact('id', 'status', 'lastUpdate', 'scoreDatas', 'topRankerScore')); } } diff --git a/OngekiScoreLog/app/ScoreData.php b/OngekiScoreLog/app/ScoreData.php index 8b239c4b..96779ab4 100644 --- a/OngekiScoreLog/app/ScoreData.php +++ b/OngekiScoreLog/app/ScoreData.php @@ -193,19 +193,6 @@ function getRecentUserScore($id){ return $this; } - function getTopRankerScore(){ - $sql = DB::table($this->table) - ->select('song_id', 'difficulty', - DB::raw('MAX(over_damage_high_score) as max_over_damage_high_score'), - DB::raw('MAX(battle_high_score) as max_battle_high_score'), - DB::raw('MAX(technical_high_score) as max_technical_high_score'),) - ->from($this->table) - ->groupBy('song_id', 'difficulty') - ; - $this->value = $sql->get(); - return $this; - } - /** * 指定した世代のスコアデータを取得します。 * diff --git a/OngekiScoreLog/database/migrations/2024_04_15_181601_create_aggregate_overdamage.php b/OngekiScoreLog/database/migrations/2024_04_15_181601_create_aggregate_overdamage.php new file mode 100644 index 00000000..b2cd730a --- /dev/null +++ b/OngekiScoreLog/database/migrations/2024_04_15_181601_create_aggregate_overdamage.php @@ -0,0 +1,34 @@ +string('id')->primary(); + $table->integer('song_id')->unsigned(); + $table->integer("difficulty")->unsigned(); + $table->decimal("max", 6, 2); + $table->timestamps(); + }); + } + + /** + * Reverse the migrations. + * + * @return void + */ + public function down() + { + Schema::dropIfExists('aggregate_overdamage'); + } +} diff --git a/OngekiScoreLog/resources/views/admin/_submenu.blade.php b/OngekiScoreLog/resources/views/admin/_submenu.blade.php index 8fd8bda1..54f48259 100644 --- a/OngekiScoreLog/resources/views/admin/_submenu.blade.php +++ b/OngekiScoreLog/resources/views/admin/_submenu.blade.php @@ -10,4 +10,11 @@ @else
id | +max | +updated_at | +
---|---|---|
{{$value->id}} | +{{$value->max}} | +{{$value->updated_at}} | +
超絶重いので実行する時間とタイミングに注意!
+登録されている全ユーザーのオーバーダメージのうち、一番高いものと比較することが出来ます。
OD埋めなどにご活用ください。
プレイしている楽曲内で、一番ODが高い難易度のみ表示されます。全難易度のODが0の曲は表示されません。なお削除楽曲等も表示されます。ご了承下さい。
+ 最終更新: {{$lastUpdate->format('Y-m-d H:i:s')}} (?%表示は未集計です)