Skip to content

Commit

Permalink
Add dashboard filters to cache key
Browse files Browse the repository at this point in the history
  • Loading branch information
robbie-c committed Oct 19, 2023
1 parent 69cfb11 commit c851102
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions posthog/models/insight.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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))
Expand Down

0 comments on commit c851102

Please sign in to comment.