Skip to content

Commit

Permalink
Make mypy happy
Browse files Browse the repository at this point in the history
  • Loading branch information
robbie-c committed Oct 19, 2023
1 parent c851102 commit 3de112b
Showing 1 changed file with 9 additions and 3 deletions.
12 changes: 9 additions & 3 deletions posthog/models/insight.py
Original file line number Diff line number Diff line change
Expand Up @@ -181,13 +181,19 @@ class Meta:
def generate_insight_cache_key(insight: Insight, dashboard: Optional[Dashboard]) -> str:
try:
if insight.query is not None:
from posthog.hogql_queries.apply_dashboard_filters import apply_dashboard_filters
dashboard_filters = dashboard.filters if dashboard else None

if dashboard_filters:
from posthog.hogql_queries.apply_dashboard_filters import apply_dashboard_filters

q = apply_dashboard_filters(insight.query, dashboard_filters, insight.team)
else:
q = insight.query

q = apply_dashboard_filters(insight.query, dashboard.filters, insight.team)
if q.get("source"):
q = q["source"]

return generate_cache_key("{}_{}_{}".format(q, dashboard.filters, 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 3de112b

Please sign in to comment.