recalculating only the new hanchans shoud do the trick now.

the racalc cronjob reports erronous partly recalculations now.
A lot of code cleanups
This commit is contained in:
2017-11-01 09:53:52 +01:00
parent ec8761b868
commit f3d44b743b
15 changed files with 87 additions and 62 deletions

View File

@@ -5,6 +5,8 @@ Recalculate Mahjong Rankings...
"""
from django.core.management.base import BaseCommand
from mahjong_ranking import LOGGER
from mahjong_ranking import models
@@ -14,5 +16,16 @@ class Command(BaseCommand):
help = "Recalculate all Kyu/Dan Rankings"
def handle(self, *args, **options):
old_attr = {'dan': None, 'dan_points': None,
'kyu': None, 'kyu_points': None, 'won_hanchans': None,
'good_hanchans': None, 'hanchan_count': None}
for ranking in models.KyuDanRanking.objects.all():
old_attr = {attr: getattr(ranking, attr) for attr in old_attr.keys()}
ranking.recalculate()
for attr, old_value in old_attr.items():
if getattr(ranking, attr) != old_value:
LOGGER.warning(
"%(user)s recalc shows differences in %(attr)s! old: %(old)d, new: %(new)d",
{'user': ranking.user, 'attr': attr,
'old': old_value, 'new': getattr(ranking, attr)}
)