Skip to content

Commit

Permalink
cosmetic
Browse files Browse the repository at this point in the history
  • Loading branch information
majdyz committed Jan 19, 2025
1 parent d2801f0 commit e9d19c4
Showing 1 changed file with 3 additions and 6 deletions.
9 changes: 3 additions & 6 deletions autogpt_platform/backend/backend/data/credit.py
Original file line number Diff line number Diff line change
Expand Up @@ -399,19 +399,16 @@ async def get_credits(self, user_id: str) -> int:
if (snapshot_time.year, snapshot_time.month) == (cur_time.year, cur_time.month):
return balance

top_up_amount = max(self.num_user_credits_refill - balance, 0)
running_balance = balance + top_up_amount
try:
return await self._add_transaction(
user_id=user_id,
amount=top_up_amount,
amount=max(self.num_user_credits_refill - balance, 0),
transaction_type=CreditTransactionType.TOP_UP,
transaction_key=f"MONTHLY-CREDIT-TOP-UP-{cur_time}",
)
except UniqueViolationError:
pass # Already refilled this month

return running_balance
# Already refilled this month
return (await self._get_credits(user_id))[0]


class DisabledUserCredit(UserCreditBase):
Expand Down

0 comments on commit e9d19c4

Please sign in to comment.