Skip to content

Commit

Permalink
fix(key_management_endpoints.py): if budget duration set, set budget_…
Browse files Browse the repository at this point in the history
…reset_at
  • Loading branch information
krrishdholakia committed Jul 24, 2024
1 parent dc3b39c commit b5c5ed2
Showing 1 changed file with 7 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -333,6 +333,13 @@ async def update_key_fn(
expires = datetime.now(timezone.utc) + timedelta(seconds=duration_s)
non_default_values["expires"] = expires

if "budget_duration" in non_default_values:
duration_s = _duration_in_seconds(
duration=non_default_values["budget_duration"]
)
key_reset_at = datetime.now(timezone.utc) + timedelta(seconds=duration_s)
non_default_values["budget_reset_at"] = key_reset_at

response = await prisma_client.update_data(
token=key, data={**non_default_values, "token": key}
)
Expand Down

0 comments on commit b5c5ed2

Please sign in to comment.