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.

fix(data-modeling): exclude deleted saved queries from freshness scheduling (#69577)

Jovan Sakovic69d42165a6ec
diff --git a/products/data_modeling/backend/logic/node_frequency.py b/products/data_modeling/backend/logic/node_frequency.py
index 627eb849c6a9..6dc422896c45 100644
--- a/products/data_modeling/backend/logic/node_frequency.py
+++ b/products/data_modeling/backend/logic/node_frequency.py
@@ -140,7 +140,7 @@ class FrequencyGraph:
def build_frequency_graph(dag: DAG) -> FrequencyGraph:
"""Extract the freshness graph for a DAG: schedulable nodes, edges, targets, source floors."""
- nodes = list(Node.objects.filter(dag=dag))
+ nodes = list(Node.objects.filter(dag=dag).exclude(saved_query__deleted=True))
edges = [
(str(source_id), str(target_id))
for source_id, target_id in Edge.objects.filter(dag=dag).values_list("source_id", "target_id")
@@ -175,7 +175,12 @@ def seed_targets(dag: DAG) -> dict[str, timedelta]:
the preview overlays these in memory, and a backfill can persist them.
"""
seeds: dict[str, timedelta] = {}
- for node in Node.objects.filter(dag=dag).exclude(type=NodeType.TABLE).select_related("saved_query"):
+ for node in (
+ Node.objects.filter(dag=dag)
+ .exclude(type=NodeType.TABLE)
+ .exclude(saved_query__deleted=True)
+ .select_related("saved_query")
+ ):
interval = None
if node.saved_query is not None and node.saved_query.sync_frequency_interval is not None:
interval = node.saved_query.sync_frequency_interval