Commit 5739d212 authored by Lukas Burgey's avatar Lukas Burgey

Add Glicko2 rd to STATS

parent 31144f1c
......@@ -21,6 +21,7 @@ STAT_DESCRIPTION = {}
STATS = [
'elo',
'glicko2',
'glicko2_rd',
'points',
'pointsperpart',
......@@ -128,7 +129,13 @@ def _elo_history():
return elo_ratings
def glicko2_history():
return get_cached(modules[__name__], '_glicko2_history')
ratings, _ = get_cached(modules[__name__], '_glicko2_history')
return ratings
def glicko2_rd_history():
_, rd_history = get_cached(modules[__name__], '_glicko2_history')
return rd_history
# hidden method with computation
def _glicko2_history():
glicko2 = Glicko2(800, 100, 0.1, 1.2)
......@@ -137,7 +144,11 @@ def _glicko2_history():
ratings_return = {}
for player in players:
ratings_return[player] = [rating.rating for rating in ratings[player]]
return ratings_return
rd_return = {}
for player in players:
rd_return[player] = [rating.rd for rating in ratings[player]]
return ratings_return, rd_return
def __glicko2(players, periods, glicko2):
......@@ -315,6 +326,10 @@ class Player(dbmodels.Model):
def glicko2(self, it):
return glicko2_history()[self][-1]
STAT_DESCRIPTION['glicko2_rd'] = "Glicko2 rating deviation", "RD"
def glicko2_rd(self, it):
return glicko2_rd_history()[self][-1]
STAT_DESCRIPTION['streaks'] = "Streaks","Str"
def streaks(self, it):
played_games = self.played_games(it).values_list('won', flat=True)
......
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