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:
@@ -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)}
|
||||
)
|
||||
|
||||
Reference in New Issue
Block a user