From c85110203216e77cba5e5b33ec1168f644d3b070 Mon Sep 17 00:00:00 2001 From: Robbie Coomber Date: Thu, 19 Oct 2023 10:07:10 +0100 Subject: [PATCH] Add dashboard filters to cache key --- posthog/models/insight.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/posthog/models/insight.py b/posthog/models/insight.py index 5f1ac36829fabf..3e420e4a80c13b 100644 --- a/posthog/models/insight.py +++ b/posthog/models/insight.py @@ -154,7 +154,7 @@ def dashboard_filters(self, dashboard: Optional[Dashboard] = None): else: return self.filters - def dashboard_query(self, dashboard: Optional[Dashboard]): + def dashboard_query(self, dashboard: Optional[Dashboard]) -> dict: if not dashboard or not self.query: return self.query from posthog.hogql_queries.apply_dashboard_filters import apply_dashboard_filters @@ -187,7 +187,7 @@ def generate_insight_cache_key(insight: Insight, dashboard: Optional[Dashboard]) if q.get("source"): q = q["source"] - return generate_cache_key("{}_{}".format(q, insight.team_id)) + return generate_cache_key("{}_{}_{}".format(q, dashboard.filters, insight.team_id)) dashboard_insight_filter = get_filter(data=insight.dashboard_filters(dashboard=dashboard), team=insight.team) candidate_filters_hash = generate_cache_key("{}_{}".format(dashboard_insight_filter.toJSON(), insight.team_id))