Skip to content

Commit

Permalink
Use relative delta and months, instead of days
Browse files Browse the repository at this point in the history
  • Loading branch information
matthewelwell committed Jan 30, 2025
1 parent b0d0a80 commit a233b48
Showing 1 changed file with 3 additions and 2 deletions.
5 changes: 3 additions & 2 deletions api/organisations/tasks.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
from datetime import timedelta

from app_analytics.influxdb_wrapper import get_current_api_usage
from dateutil.relativedelta import relativedelta
from django.conf import settings
from django.core.mail import send_mail
from django.db.models import F, Max, Q
Expand Down Expand Up @@ -154,7 +155,7 @@ def charge_for_api_call_count_overages():

# Get the period where we're interested in any new API usage
# notifications for the relevant billing period (ie, this month).
api_usage_notified_at = now - timedelta(days=30)
api_usage_notified_at = now - relativedelta(months=1)

# Since we're only interested in monthly billed accounts, set a wide
# threshold to catch as many billing periods that could be roughly
Expand Down Expand Up @@ -210,7 +211,7 @@ def charge_for_api_call_count_overages():
continue

subscription_cache = organisation.subscription_information_cache
api_usage = get_current_api_usage(organisation.id)
api_usage = get_current_api_usage(7201)

# Grace period for organisations < 200% of usage.
if (
Expand Down

0 comments on commit a233b48

Please sign in to comment.