Skip to content

Commit

Permalink
Run the task more frequently
Browse files Browse the repository at this point in the history
  • Loading branch information
zachaysan committed May 3, 2024
1 parent 5142c39 commit 33251c1
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 4 deletions.
5 changes: 3 additions & 2 deletions api/organisations/tasks.py
Original file line number Diff line number Diff line change
Expand Up @@ -217,7 +217,7 @@ def charge_for_api_call_count_overages():

# Only apply charges to ongoing subscriptions that are close to
# being charged due to being at the end of the billing term.
closing_billing_term = now + timedelta(hours=12)
closing_billing_term = now + timedelta(hours=1)

organisation_ids = set(
OrganisationAPIUsageNotification.objects.filter(
Expand Down Expand Up @@ -284,6 +284,7 @@ def charge_for_api_call_count_overages():
register_recurring_task(
run_every=timedelta(hours=12),
)(handle_api_usage_notifications)

register_recurring_task(
run_every=timedelta(hours=12),
run_every=timedelta(minutes=30),
)(charge_for_api_call_count_overages)
4 changes: 2 additions & 2 deletions api/tests/unit/organisations/test_unit_organisations_tasks.py
Original file line number Diff line number Diff line change
Expand Up @@ -470,7 +470,7 @@ def test_charge_for_api_call_count_overages_scale_up(
allowed_30d_api_calls=10_000,
chargebee_email="test@example.com",
current_billing_term_starts_at=now - timedelta(days=30),
current_billing_term_ends_at=now + timedelta(hours=6),
current_billing_term_ends_at=now + timedelta(minutes=30),
)
organisation.subscription.subscription_id = "fancy_sub_id23"
organisation.subscription.plan = "scale-up-v2"
Expand Down Expand Up @@ -532,7 +532,7 @@ def test_charge_for_api_call_count_overages_start_up(
allowed_30d_api_calls=10_000,
chargebee_email="test@example.com",
current_billing_term_starts_at=now - timedelta(days=30),
current_billing_term_ends_at=now + timedelta(hours=6),
current_billing_term_ends_at=now + timedelta(minutes=30),
)
organisation.subscription.subscription_id = "fancy_sub_id23"
organisation.subscription.plan = "startup-v2"
Expand Down

0 comments on commit 33251c1

Please sign in to comment.