From fb98316113fa2eef3fae195156805d5ab05c7893 Mon Sep 17 00:00:00 2001 From: NECROshizo Date: Sat, 6 Apr 2024 23:13:12 +0300 Subject: [PATCH] extra fix add reward achievement --- backend/utils/achievements.py | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/backend/utils/achievements.py b/backend/utils/achievements.py index 5c9f38a..e8ab2be 100644 --- a/backend/utils/achievements.py +++ b/backend/utils/achievements.py @@ -140,7 +140,12 @@ def _update_database(self): user_achievements = [ UserAchievement(user_id=self._user, achievement_id=achievement) for achievement in self._new_achievements ] + rewards = sum( + [achievement.reward_points for achievement in self._new_achievements] + ) # XXX: проверить и прорефакторить + self._user.amount_of_skips += rewards with transaction.atomic(): + self._user.save() UserAchievement.objects.filter( user_id=self._user, achievement_id__in=self._new_achievements, achievement_id__recurring=True ).delete() @@ -170,6 +175,7 @@ def _query_unfinished_achievements(self): id__in=UserAchievement.objects.filter(user_id=self._user.id).values("achievement_id") ) self._unfinished_achievements = unfinished_non_ios | recurring_non_ios + # from django.db.models import Q # self._unfinished_achievements = Achievement.objects.exclude( # Q(id__in=UserAchievement.objects.filter(