Skip to content

Commit

Permalink
fix(backfill-batch-exports): Do not run partial ranges (#18114)
Browse files Browse the repository at this point in the history
  • Loading branch information
tomasfarias authored Oct 19, 2023
1 parent 1dc09c2 commit aaf76ac
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 1 deletion.
15 changes: 15 additions & 0 deletions posthog/temporal/tests/batch_exports/test_backfill_batch_export.py
Original file line number Diff line number Diff line change
Expand Up @@ -128,6 +128,21 @@ async def temporal_worker(temporal_client):
)
],
),
(
dt.datetime(2023, 1, 1, 10, 0, 0, tzinfo=dt.timezone.utc),
dt.datetime(2023, 1, 1, 12, 20, 0, tzinfo=dt.timezone.utc),
dt.timedelta(hours=1),
[
(
dt.datetime(2023, 1, 1, 10, 0, 0, tzinfo=dt.timezone.utc),
dt.datetime(2023, 1, 1, 11, 0, 0, tzinfo=dt.timezone.utc),
),
(
dt.datetime(2023, 1, 1, 11, 0, 0, tzinfo=dt.timezone.utc),
dt.datetime(2023, 1, 1, 12, 0, 0, tzinfo=dt.timezone.utc),
),
],
),
(
dt.datetime(2023, 1, 1, 0, 0, 0, tzinfo=dt.timezone.utc),
dt.datetime(2023, 1, 2, 0, 0, 0, tzinfo=dt.timezone.utc),
Expand Down
4 changes: 3 additions & 1 deletion posthog/temporal/workflows/backfill_batch_export.py
Original file line number Diff line number Diff line change
Expand Up @@ -244,7 +244,9 @@ def backfill_range(
current_end = current + step

if current_end > end_at:
current_end = end_at
# Do not yield a range that is less than step.
# Same as built-in range.
break

yield current, current_end

Expand Down

0 comments on commit aaf76ac

Please sign in to comment.