Skip to content

Commit

Permalink
fix: delay usage report sending on sunday (#18900)
Browse files Browse the repository at this point in the history
delay usage report sending on sunday
  • Loading branch information
raquelmsmith authored Nov 27, 2023
1 parent 9299aa0 commit 0c37f8b
Showing 1 changed file with 11 additions and 2 deletions.
13 changes: 11 additions & 2 deletions posthog/celery.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,9 +26,9 @@

from posthog.cloud_utils import is_cloud
from posthog.metrics import pushed_metrics_registry
from posthog.ph_client import get_ph_client
from posthog.redis import get_client
from posthog.utils import get_crontab
from posthog.ph_client import get_ph_client

# set the default Django settings module for the 'celery' program.
os.environ.setdefault("DJANGO_SETTINGS_MODULE", "posthog.settings")
Expand Down Expand Up @@ -148,11 +148,18 @@ def setup_periodic_tasks(sender: Celery, **kwargs):
)

# Send all instance usage to the Billing service
# Sends later on Sunday due to clickhouse things that happen on Sunday at ~00:00 UTC
sender.add_periodic_task(
crontab(hour="0", minute="5"),
crontab(hour="2", minute="5", day_of_week="sun"),
send_org_usage_reports.s(),
name="send instance usage report",
)
sender.add_periodic_task(
crontab(hour="0", minute="5", day_of_week="mon,tue,wed,thu,fri,sat"),
send_org_usage_reports.s(),
name="send instance usage report",
)

# Update local usage info for rate limiting purposes - offset by 30 minutes to not clash with the above
sender.add_periodic_task(
crontab(hour="*", minute="30"),
Expand Down Expand Up @@ -905,6 +912,7 @@ def debug_task(self):
@app.task(ignore_result=True)
def calculate_decide_usage() -> None:
from django.db.models import Q

from posthog.models import Team
from posthog.models.feature_flag.flag_analytics import capture_team_decide_usage

Expand All @@ -921,6 +929,7 @@ def calculate_decide_usage() -> None:
@app.task(ignore_result=True)
def calculate_external_data_rows_synced() -> None:
from django.db.models import Q

from posthog.models import Team
from posthog.tasks.warehouse import (
capture_workspace_rows_synced_by_team,
Expand Down

0 comments on commit 0c37f8b

Please sign in to comment.