Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: Set billing starts at to reasonable default for API usage notifications #4054

Merged
merged 1 commit into from
May 30, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions api/organisations/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
from __future__ import unicode_literals

import logging
from datetime import timedelta

from app_analytics.influxdb_wrapper import (
get_events_for_organisation,
Expand Down Expand Up @@ -324,6 +325,10 @@ def get_queryset(self):
billing_starts_at = subscription_cache.current_billing_term_starts_at
now = timezone.now()

# Handle case where billing dates are not set by
# defaulting to something as a reasonable default.
billing_starts_at = billing_starts_at or now - timedelta(days=30)

month_delta = relativedelta(now, billing_starts_at).months
period_starts_at = relativedelta(months=month_delta) + billing_starts_at

Expand Down