Skip to content

:hedgehog: PostHog is the leading platform for building self-driving products. Our developer tools – AI observability, analytics, session replay, flags, experiments, error tracking, logs, and more – capture all the context agents need to diagnose problems, uncover opportunities, and ship fixes. Steer it all from Slack, web, desktop, or the MCP.

feat(data-modeling): filter full schedule sweep by PostHogScheduleType (#67345)

Jovan Sakovic9c9488745d89
diff --git a/products/data_modeling/backend/schedule.py b/products/data_modeling/backend/schedule.py
index 2363f05ea6f8..2ea58c04015a 100644
--- a/products/data_modeling/backend/schedule.py
+++ b/products/data_modeling/backend/schedule.py
@@ -60,7 +60,8 @@ async def get_v2_scheduled_dag_ids(candidate_dag_ids: Collection[str] | None = N
When `candidate_dag_ids` is given, the listing is scoped server-side to those DAGs via the
`PostHogDagId` search attribute so we never paginate every schedule in the namespace — a
single unscoped listing per saved-query operation is enough to exhaust the namespace rate
- limit once the schedule fleet is large. Pass None only for genuine full-namespace sweeps.
+ limit once the schedule fleet is large. The None sweep filters on `PostHogScheduleType`
+ (needs schedules backfilled with the tag).
"""
if candidate_dag_ids is not None and not candidate_dag_ids:
return set()
@@ -72,7 +73,9 @@ async def get_v2_scheduled_dag_ids(candidate_dag_ids: Collection[str] | None = N
quoted = ", ".join(f"'{dag_id}'" for dag_id in candidate_dag_ids)
schedules = await temporal.list_schedules(query=f"{POSTHOG_DAG_ID_KEY.name} IN ({quoted})")
else:
- schedules = await temporal.list_schedules()
+ schedules = await temporal.list_schedules(
+ query=f'{POSTHOG_SCHEDULE_TYPE_KEY.name} = "{DATA_MODELING_EXECUTE_DAG_WORKFLOW}"'
+ )
dag_ids: set[str] = set()
async for listing in schedules:
diff --git a/products/data_modeling/backend/test/test_schedule.py b/products/data_modeling/backend/test/test_schedule.py
index bfe57d9bd5f5..151977b3a004 100644
--- a/products/data_modeling/backend/test/test_schedule.py
+++ b/products/data_modeling/backend/test/test_schedule.py
@@ -315,7 +315,7 @@ class TestGetV2ScheduledDagIds:
action = mock.Mock(spec=ScheduleListActionStartWorkflow, workflow=workflow)
return mock.Mock(id=schedule_id, schedule=mock.Mock(action=action))
- def test_lists_client_side_without_workflowtype_query(self):
+ def test_full_sweep_scopes_by_schedule_type_server_side(self):
captured: dict = {}
listings = [
self._listing("dag-on-v2", "data-modeling-execute-dag"),
@@ -323,7 +323,6 @@ class TestGetV2ScheduledDagIds:
]
async def fake_list_schedules(*args, **kwargs):
- captured["args"] = args
captured["kwargs"] = kwargs
async def gen():
@@ -340,10 +339,9 @@ class TestGetV2ScheduledDagIds:
):
result = get_v2_scheduled_dag_ids()
- # The schedule visibility store rejects filtering on WorkflowType, so we must not pass a
- # server-side query and must filter the listings client-side instead.
- assert captured["args"] == ()
- assert "query" not in captured["kwargs"]
+ # WorkflowType isn't queryable on schedules, so the full sweep scopes server-side on the
+ # PostHogScheduleType tag instead of paginating the whole namespace.
+ assert captured["kwargs"]["query"] == 'PostHogScheduleType = "data-modeling-execute-dag"'
assert result == {"dag-on-v2"}
def test_scopes_listing_by_posthog_dag_id_when_candidates_given(self):