Commit 5f785213 authored by Jack Stupple's avatar Jack Stupple

make the season_roundup_position determined by the history count

parent 90c72064
......@@ -39,7 +39,7 @@ class Character extends Model
public function profile_picture()
{
$player = get_player($_SERVER['HTTP_SESSION_ID'], false);
return $this->hasOne(\App\CharacterPicture::class)
->where('season_roundup_position', '=', $player ? $player->season_roundup_position : 0);
}
......
......@@ -98,33 +98,6 @@ class Player extends Model
public function getSeasonRoundupPositionAttribute()
{
/**
* SELECT ph.`season_roundup_position`
* FROM `player_history` ph
* LEFT JOIN `players` p ON ph.`player_id` = p.`id`
* WHERE `player_id` = 11
* AND ph.`season_roundup_id` IS NOT NULL
* AND ph.`playthrough` = p.`playthrough`
* GROUP BY ph.`season_roundup_position`
* ORDER BY ph.`season_roundup_position` DESC
*/
$roundup_position = DB::table('player_history')
->select('season_roundup_position')
->where('player_id', $this->id)
->where('season_roundup_id', '!=', null)
->where('playthrough', '=', $this->playthrough)
->groupBy('season_roundup_position')
->orderBy('season_roundup_position', 'DESC')
->limit(1)
->first();
// emulate a response with 0 - we have not had a roundup yet
if (!$roundup_position) {
$roundup_position = (object) [
'season_roundup_position' => 0
];
}
return $roundup_position->season_roundup_position;
return floor($this->progress / 3);
}
}
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment