From 50f9a87018a3a05be0730b60c4a6823a03e0ce9e Mon Sep 17 00:00:00 2001 From: ice-myles <96409608+ice-myles@users.noreply.github.com> Date: Wed, 20 Dec 2023 14:38:31 +0300 Subject: [PATCH] Revert "Removed achieved badges check to update balances for each user" (#34) --- badges/achieve_badges.go | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/badges/achieve_badges.go b/badges/achieve_badges.go index 4f4739d..a368452 100644 --- a/badges/achieve_badges.go +++ b/badges/achieve_badges.go @@ -374,7 +374,8 @@ func (s *balancesTableSource) upsertProgress(ctx context.Context, balance int64, return errors.Wrap(ctx.Err(), "context failed") } pr, err := s.getProgress(ctx, userID, true) - if err != nil && !errors.Is(err, storage.ErrRelationNotFound) { + if err != nil && !errors.Is(err, storage.ErrRelationNotFound) || + (pr != nil && pr.AchievedBadges != nil && (len(*pr.AchievedBadges) == len(&AllTypes) || IsBadgeGroupAchieved(pr.AchievedBadges, CoinGroupType))) { return errors.Wrapf(err, "failed to getProgress for userID:%v", userID) } if pr != nil && pr.Balance == balance {