Skip to content

Commit 0c29403

Browse files
committed
hotfix(backend): Fix month credit calculation on December (#8851)
1 parent d26105d commit 0c29403

File tree

1 file changed

+5
-1
lines changed
  • autogpt_platform/backend/backend/data

1 file changed

+5
-1
lines changed

autogpt_platform/backend/backend/data/credit.py

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -70,7 +70,11 @@ class UserCredit(UserCreditBase):
7070
async def get_or_refill_credit(self, user_id: str) -> int:
7171
cur_time = self.time_now()
7272
cur_month = cur_time.replace(day=1, hour=0, minute=0, second=0, microsecond=0)
73-
nxt_month = cur_month.replace(month=cur_month.month % 12 + 1)
73+
nxt_month = (
74+
cur_month.replace(month=cur_month.month + 1)
75+
if cur_month.month < 12
76+
else cur_month.replace(year=cur_month.year + 1, month=1)
77+
)
7478

7579
user_credit = await UserBlockCredit.prisma().group_by(
7680
by=["userId"],

0 commit comments

Comments
 (0)