Skip to content

Commit

Permalink
extra fix add reward achievement
Browse files Browse the repository at this point in the history
  • Loading branch information
NECROshizo committed Apr 6, 2024
1 parent 2b3cd16 commit fb98316
Showing 1 changed file with 6 additions and 0 deletions.
6 changes: 6 additions & 0 deletions backend/utils/achievements.py
Original file line number Diff line number Diff line change
Expand Up @@ -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()
Expand Down Expand Up @@ -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(
Expand Down

0 comments on commit fb98316

Please sign in to comment.