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-warehouse): scope saved query activity lookups by team (#73191)

Jovan Sakovicb960636018b2
diff --git a/products/data_warehouse/backend/presentation/views/saved_query.py b/products/data_warehouse/backend/presentation/views/saved_query.py
index b95494c01ba7..469db844f42d 100644
--- a/products/data_warehouse/backend/presentation/views/saved_query.py
+++ b/products/data_warehouse/backend/presentation/views/saved_query.py
@@ -559,6 +559,7 @@ class DataWarehouseSavedQuerySerializer(
edited_history_id = self.context["request"].data.get("edited_history_id", None)
latest_activity_id = (
ActivityLog.objects.filter(
+ team_id=locked_instance.team_id,
item_id=locked_instance.id,
scope="DataWarehouseSavedQuery",
**QUERY_CHANGE_ACTIVITY_FILTER,
@@ -678,6 +679,7 @@ class DataWarehouseSavedQuerySerializer(
# get latest query-changing activity log for this model (see QUERY_CHANGE_ACTIVITY_FILTER)
latest_activity_log = (
ActivityLog.objects.filter(
+ team_id=locked_instance.team_id,
item_id=locked_instance.id,
scope="DataWarehouseSavedQuery",
**QUERY_CHANGE_ACTIVITY_FILTER,