Skip to content

Commit

Permalink
hotfix(backend): Fix month credit calculation on December (#8851)
Browse files Browse the repository at this point in the history
When calculating the next month, we are not rolling the month number
causing an error on credits.

### Changes πŸ—οΈ

Add modulo while calculating next month.

### Checklist πŸ“‹

#### For code changes:
- [ ] I have clearly listed my changes in the PR description
- [ ] I have made a test plan
- [ ] I have tested my changes according to the test plan:
  <!-- Put your test plan here: -->
  - [ ] ...

<details>
  <summary>Example test plan</summary>
  
  - [ ] Create from scratch and execute an agent with at least 3 blocks
- [ ] Import an agent from file upload, and confirm it executes
correctly
  - [ ] Upload agent to marketplace
- [ ] Import an agent from marketplace and confirm it executes correctly
  - [ ] Edit an agent from monitor, and confirm it executes correctly
</details>

#### For configuration changes:
- [ ] `.env.example` is updated or already compatible with my changes
- [ ] `docker-compose.yml` is updated or already compatible with my
changes
- [ ] I have included a list of my configuration changes in the PR
description (under **Changes**)

<details>
  <summary>Examples of configuration changes</summary>

  - Changing ports
  - Adding new services that need to communicate with each other
  - Secrets or environment variable changes
  - New or infrastructure changes such as databases
</details>
  • Loading branch information
majdyz authored Dec 2, 2024
1 parent 7d48eeb commit d26105d
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion autogpt_platform/backend/backend/data/credit.py
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@ class UserCredit(UserCreditBase):
async def get_or_refill_credit(self, user_id: str) -> int:
cur_time = self.time_now()
cur_month = cur_time.replace(day=1, hour=0, minute=0, second=0, microsecond=0)
nxt_month = cur_month.replace(month=cur_month.month + 1)
nxt_month = cur_month.replace(month=cur_month.month % 12 + 1)

user_credit = await UserBlockCredit.prisma().group_by(
by=["userId"],
Expand Down

0 comments on commit d26105d

Please sign in to comment.