-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #827 from project-primera/develop
release 0.17.1
- Loading branch information
Showing
12 changed files
with
190 additions
and
24 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,61 @@ | ||
<?php | ||
|
||
namespace App; | ||
|
||
use Illuminate\Database\Eloquent\Model; | ||
use Illuminate\Support\Facades\DB; | ||
|
||
class AggregateOverdamage extends Model | ||
{ | ||
protected $table = "aggregate_overdamage"; | ||
protected $guarded = [ | ||
// | ||
]; | ||
public $incrementing = false; | ||
|
||
public static function execute(){ | ||
\App\Facades\Slack::Debug("Max Over Damageの集計を開始します。"); | ||
|
||
$musics = \App\MusicData::all(); | ||
$normalDifficulties = [0, 1, 2, 3]; | ||
$lunaticDifficulty = 10; | ||
|
||
foreach ($musics as $music) { | ||
if($music->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; | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
34 changes: 34 additions & 0 deletions
34
OngekiScoreLog/database/migrations/2024_04_15_181601_create_aggregate_overdamage.php
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
<?php | ||
|
||
use Illuminate\Support\Facades\Schema; | ||
use Illuminate\Database\Schema\Blueprint; | ||
use Illuminate\Database\Migrations\Migration; | ||
|
||
class CreateAggregateOverdamage extends Migration | ||
{ | ||
/** | ||
* Run the migrations. | ||
* | ||
* @return void | ||
*/ | ||
public function up() | ||
{ | ||
Schema::create('aggregate_overdamage', function (Blueprint $table) { | ||
$table->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'); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
@extends('layouts.app') | ||
|
||
@section('title', '管理ページ') | ||
@section('hero_title', "管理ページ") | ||
@section('hero_subtitle', "config") | ||
|
||
@section('submenu') | ||
@include('admin/_submenu', ['active' => 'aggregate']) | ||
@endsection | ||
|
||
@section('content') | ||
<article class="box"> | ||
<h3 class="title is-3">集計一覧</h3> | ||
<table class="table"> | ||
<thead> | ||
<tr> | ||
<th>id</th> | ||
<th>max</th> | ||
<th>updated_at</th> | ||
</tr> | ||
</thead> | ||
<tbody> | ||
@foreach ($result as $key => $value) | ||
<tr> | ||
<td>{{$value->id}}</td> | ||
<td>{{$value->max}}</td> | ||
<td>{{$value->updated_at}}</td> | ||
</tr> | ||
@endforeach | ||
</tbody> | ||
</table> | ||
</article> | ||
@endsection |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters