diff --git a/posthog/api/team.py b/posthog/api/team.py index ca55dbbf1d032..c29732d4e2f1c 100644 --- a/posthog/api/team.py +++ b/posthog/api/team.py @@ -338,8 +338,9 @@ def create(self, validated_data: dict[str, Any], **kwargs) -> Team: return team - def _clear_team_insight_cache(self, team: Team) -> None: - # :KLUDGE: This is incorrect as it doesn't wipe caches not currently linked to insights. Fix this some day! + def _handle_timezone_update(self, team: Team) -> None: + # TODO: Remove when legacy insight calculation is no more, + # as the HogQL backend's caching always includes timezone in the cache key hashes = InsightCachingState.objects.filter(team=team).values_list("cache_key", flat=True) cache.delete_many(hashes) diff --git a/posthog/api/test/dashboards/test_dashboard.py b/posthog/api/test/dashboards/test_dashboard.py index 7eefc3cb8ebab..8f897426c3c84 100644 --- a/posthog/api/test/dashboards/test_dashboard.py +++ b/posthog/api/test/dashboards/test_dashboard.py @@ -193,6 +193,7 @@ def test_shared_dashboard(self): response = self.client.get("/shared_dashboard/testtoken") self.assertEqual(response.status_code, status.HTTP_200_OK) + @override_settings(HOGQL_INSIGHTS_OVERRIDE=False) # .../insights/trend/ can't run in HogQL yet def test_return_cached_results_bleh(self): dashboard = Dashboard.objects.create(team=self.team, name="dashboard") filter_dict = { @@ -930,6 +931,7 @@ def test_duplication_fail_for_different_team(self): expected_status=status.HTTP_400_BAD_REQUEST, ) + @override_settings(HOGQL_INSIGHTS_OVERRIDE=False) # .../insights/trend/ can't run in HogQL yet def test_return_cached_results_dashboard_has_filters(self): # Regression test, we were diff --git a/posthog/api/test/test_insight.py b/posthog/api/test/test_insight.py index ab75f8c8adec5..26b0f7a420993 100644 --- a/posthog/api/test/test_insight.py +++ b/posthog/api/test/test_insight.py @@ -1022,6 +1022,7 @@ def test_save_new_funnel(self) -> None: self.assertEqual(objects[0].filters["layout"], "horizontal") self.assertEqual(len(objects[0].short_id), 8) + @override_settings(HOGQL_INSIGHTS_OVERRIDE=False) # synchronously_update_cache is a legacy-only code path @patch("posthog.api.insight.synchronously_update_cache", wraps=synchronously_update_cache) def test_insight_refreshing_legacy(self, spy_update_insight_cache) -> None: dashboard_id, _ = self.dashboard_api.create_dashboard({"filters": {"date_from": "-14d"}}) diff --git a/posthog/api/test/test_team.py b/posthog/api/test/test_team.py index 0bf9723bdba21..896a4ba2c433f 100644 --- a/posthog/api/test/test_team.py +++ b/posthog/api/test/test_team.py @@ -7,6 +7,7 @@ from asgiref.sync import sync_to_async from django.core.cache import cache from django.http import HttpResponse +from django.test import override_settings from freezegun import freeze_time from parameterized import parameterized from rest_framework import status @@ -503,6 +504,7 @@ def test_cant_set_primary_dashboard_to_another_teams_dashboard(self): response_data = response.json() self.assertEqual(response_data["primary_dashboard"], None) + @override_settings(HOGQL_INSIGHTS_OVERRIDE=False) # .../insights/trend/ can't run in HogQL yet def test_update_timezone_remove_cache(self): # Seed cache with some insights self.client.post(