Skip to content

Commit

Permalink
Preload solo score performance
Browse files Browse the repository at this point in the history
  • Loading branch information
nanaya committed Oct 27, 2022
1 parent dde1c16 commit 06e15d3
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 0 deletions.
1 change: 1 addition & 0 deletions app/Models/Score/Best/Model.php
Original file line number Diff line number Diff line change
Expand Up @@ -85,6 +85,7 @@ public function getAttribute($key)
'best' => $this,
'data' => $this->getData(),
'enabled_mods' => $this->getEnabledModsAttribute($this->getRawAttribute('enabled_mods')),
'nonexistent' => null,
'pass' => true,

'beatmap',
Expand Down
7 changes: 7 additions & 0 deletions app/Models/Score/Model.php
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
use App\Models\Beatmap;
use App\Models\Model as BaseModel;
use App\Models\Solo\ScoreData;
use App\Models\Solo\ScorePerformance;
use App\Models\Traits\Scoreable;
use App\Models\User;

Expand Down Expand Up @@ -114,6 +115,11 @@ public function best()
return $this->belongsTo("App\\Models\\Score\\Best\\{$basename}", 'high_score_id', 'score_id');
}

public function performance()
{
return $this->belongsTo(ScorePerformance::class, 'nonexistent');
}

public function user()
{
return $this->belongsTo(User::class, 'user_id');
Expand Down Expand Up @@ -148,6 +154,7 @@ public function getAttribute($key)

'data' => $this->getData(),
'enabled_mods' => $this->getEnabledModsAttribute($this->getRawAttribute('enabled_mods')),
'nonexistent' => null,

'beatmap',
'best',
Expand Down
1 change: 1 addition & 0 deletions app/Transformers/ScoreTransformer.php
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ class ScoreTransformer extends TransformerAbstract
const USER_PROFILE_INCLUDES_PRELOAD = [
'beatmap',
'beatmap.beatmapset',
'performance',
// it's for user profile so the user is already available
// 'user',
];
Expand Down

0 comments on commit 06e15d3

Please sign in to comment.