Skip to content

Commit

Permalink
feat: Cap number of emails to one per day
Browse files Browse the repository at this point in the history
  • Loading branch information
tomasfarias committed Apr 17, 2024
1 parent b8b9acb commit 6d3382a
Showing 1 changed file with 7 additions and 1 deletion.
8 changes: 7 additions & 1 deletion posthog/tasks/email.py
Original file line number Diff line number Diff line change
Expand Up @@ -171,7 +171,13 @@ async def send_batch_export_run_failure(
BatchExportRun.objects.select_related("batch_export__team").get
)(id=batch_export_run_id)
team: Team = batch_export_run.batch_export.team
campaign_key: str = f"batch_export_run_email_batch_export_{batch_export_run.batch_export.id}_data_interval_end_{batch_export_run.data_interval_end}"
# NOTE: We are taking only the date component to cap the number of emails at one per day per batch export.
last_updated_at_date = batch_export_run.last_updated_at.strftime("%Y-%m-%d")

campaign_key: (
str
) = f"batch_export_run_email_batch_export_{batch_export_run.batch_export.id}_last_updated_at_{last_updated_at_date}"

message = await sync_to_async(EmailMessage)(
campaign_key=campaign_key,
subject=f"PostHog: {batch_export_run.batch_export.name} batch export run failure",
Expand Down

0 comments on commit 6d3382a

Please sign in to comment.