fix to challenge average score
This commit is contained in:
parent
17d64c1479
commit
dd1fd1c80f
@ -80,7 +80,10 @@ class Challenge(models.Model):
|
||||
@property
|
||||
def average(self):
|
||||
#this should be cached, but with low volumes its fine as is
|
||||
return int(round(Game.objects.filter(challenge=self).aggregate(Avg('score')).get('score__avg', 0)))
|
||||
if Game.objects.filter(challenge=self):
|
||||
return int(round(Game.objects.filter(challenge=self).aggregate(Avg('score')).get('score__avg', 0)))
|
||||
else:
|
||||
return 0
|
||||
|
||||
@property
|
||||
def num_rounds(self):
|
||||
@ -148,4 +151,4 @@ class GameRound(models.Model):
|
||||
self.result = 0
|
||||
else:
|
||||
self.result = int(round(14.46 * (11.52 - math.log(dst))))
|
||||
super().save(*args, **kwargs)
|
||||
super().save(*args, **kwargs)
|
||||
|
@ -24,7 +24,7 @@ with open(os.path.join(BASE_DIR, "env_secret_key.txt")) as secret_key:
|
||||
SECRET_KEY = secret_key.read().strip()
|
||||
|
||||
# SECURITY WARNING: don't run with debug turned on in production!
|
||||
DEBUG = True
|
||||
DEBUG = False
|
||||
|
||||
ALLOWED_HOSTS = ['*']
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user