diff --git a/frontend/src/lib/api.ts b/frontend/src/lib/api.ts index 85909b193e4b7..720c3c3642887 100644 --- a/frontend/src/lib/api.ts +++ b/frontend/src/lib/api.ts @@ -889,7 +889,6 @@ const api = { .withQueryString( toParams({ short_id: encodeURIComponent(shortId), - include_query_insights: true, basic: basic, }) ) diff --git a/frontend/src/scenes/project-homepage/projectHomepageLogic.tsx b/frontend/src/scenes/project-homepage/projectHomepageLogic.tsx index bc60ea973c73a..b9581cffe2bd4 100644 --- a/frontend/src/scenes/project-homepage/projectHomepageLogic.tsx +++ b/frontend/src/scenes/project-homepage/projectHomepageLogic.tsx @@ -33,9 +33,7 @@ export const projectHomepageLogic = kea([ [] as InsightModel[], { loadRecentInsights: async () => { - return await api.get( - `api/projects/${values.currentTeamId}/insights/my_last_viewed?include_query_insights=true` - ) + return await api.get(`api/projects/${values.currentTeamId}/insights/my_last_viewed`) }, }, ], diff --git a/frontend/src/scenes/saved-insights/savedInsightsLogic.ts b/frontend/src/scenes/saved-insights/savedInsightsLogic.ts index 855de9b832ee3..2cba409f7f638 100644 --- a/frontend/src/scenes/saved-insights/savedInsightsLogic.ts +++ b/frontend/src/scenes/saved-insights/savedInsightsLogic.ts @@ -95,7 +95,6 @@ export const savedInsightsLogic = kea([ const params = { ...values.paramsFromFilters, basic: true, - include_query_insights: true, } const response = await api.get( @@ -105,7 +104,7 @@ export const savedInsightsLogic = kea([ if (filters.search && String(filters.search).match(/^[0-9]+$/)) { try { const insight: InsightModel = await api.get( - `api/projects/${teamLogic.values.currentTeamId}/insights/${filters.search}/?include_query_insights=true` + `api/projects/${teamLogic.values.currentTeamId}/insights/${filters.search}/` ) return { ...response, diff --git a/posthog/api/insight.py b/posthog/api/insight.py index 116841d004e3f..089b2ffe06ff0 100644 --- a/posthog/api/insight.py +++ b/posthog/api/insight.py @@ -675,9 +675,6 @@ def safely_get_queryset(self, queryset) -> QuerySet: queryset = queryset.prefetch_related("tagged_items__tag") queryset = self._filter_request(self.request, queryset) - if self.request.query_params.get("include_query_insights", "false").lower() != "true": - queryset = queryset.exclude(Q(filters={}) & Q(query__isnull=False)) - order = self.request.GET.get("order", None) if order: queryset = queryset.order_by(order) @@ -697,8 +694,6 @@ def my_last_viewed(self, request: request.Request, *args, **kwargs) -> Response: .exclude(insight__deleted=True) .only("insight") ) - if self.request.query_params.get("include_query_insights", "false").lower() != "true": - insight_queryset = insight_queryset.exclude(Q(insight__filters={}) & Q(insight__query__isnull=False)) recently_viewed = [rv.insight for rv in (insight_queryset.order_by("-last_viewed_at")[:5])] diff --git a/posthog/api/test/__snapshots__/test_insight.ambr b/posthog/api/test/__snapshots__/test_insight.ambr index 972bf8c24e289..2cec6497667e0 100644 --- a/posthog/api/test/__snapshots__/test_insight.ambr +++ b/posthog/api/test/__snapshots__/test_insight.ambr @@ -1212,8 +1212,6 @@ SELECT COUNT(*) AS "__count" FROM "posthog_dashboarditem" WHERE (NOT ("posthog_dashboarditem"."deleted") - AND NOT ("posthog_dashboarditem"."filters" = '{}'::jsonb - AND "posthog_dashboarditem"."query" IS NOT NULL) AND "posthog_dashboarditem"."team_id" = 2) ''' # --- @@ -1359,8 +1357,6 @@ LEFT OUTER JOIN "posthog_user" ON ("posthog_dashboarditem"."created_by_id" = "posthog_user"."id") LEFT OUTER JOIN "posthog_user" T4 ON ("posthog_dashboarditem"."last_modified_by_id" = T4."id") WHERE (NOT ("posthog_dashboarditem"."deleted") - AND NOT ("posthog_dashboarditem"."filters" = '{}'::jsonb - AND "posthog_dashboarditem"."query" IS NOT NULL) AND "posthog_dashboarditem"."team_id" = 2) ORDER BY "posthog_dashboarditem"."order" ASC LIMIT 100 diff --git a/posthog/api/test/test_insight.py b/posthog/api/test/test_insight.py index 1fce31df54a8d..9402b996b1990 100644 --- a/posthog/api/test/test_insight.py +++ b/posthog/api/test/test_insight.py @@ -2438,7 +2438,7 @@ def test_get_recently_viewed_insights(self) -> None: self.assertEqual(response.status_code, status.HTTP_200_OK) assert [r["id"] for r in response_data] == [insight_1_id] - def test_get_recently_viewed_insights_excludes_query_based_insights_by_default(self) -> None: + def test_get_recently_viewed_insights_include_query_based_insights(self) -> None: insight_1_id, _ = self.dashboard_api.create_insight({"short_id": "12345678"}) insight_2_id, _ = self.dashboard_api.create_insight( { @@ -2475,48 +2475,6 @@ def test_get_recently_viewed_insights_excludes_query_based_insights_by_default(s response = self.client.get(f"/api/projects/{self.team.id}/insights/my_last_viewed") response_data = response.json() - # No results if no insights have been viewed - self.assertEqual(response.status_code, status.HTTP_200_OK) - assert [r["id"] for r in response_data] == [insight_1_id] - - def test_get_recently_viewed_insights_can_include_query_based_insights(self) -> None: - insight_1_id, _ = self.dashboard_api.create_insight({"short_id": "12345678"}) - insight_2_id, _ = self.dashboard_api.create_insight( - { - "short_id": "3456", - "query": { - "kind": "DataTableNode", - "source": { - "kind": "EventsQuery", - "select": [ - "*", - "event", - "person", - "coalesce(properties.$current_url, properties.$screen_name)", - "properties.$lib", - "timestamp", - ], - "properties": [ - { - "type": "event", - "key": "$browser", - "operator": "exact", - "value": "Chrome", - } - ], - "limit": 100, - }, - }, - } - ) - - self.client.post(f"/api/projects/{self.team.id}/insights/{insight_1_id}/viewed") - self.client.post(f"/api/projects/{self.team.id}/insights/{insight_2_id}/viewed") - - response = self.client.get(f"/api/projects/{self.team.id}/insights/my_last_viewed?include_query_insights=true") - response_data = response.json() - - # No results if no insights have been viewed self.assertEqual(response.status_code, status.HTTP_200_OK) assert [r["id"] for r in response_data] == [insight_2_id, insight_1_id] diff --git a/posthog/api/test/test_insight_query.py b/posthog/api/test/test_insight_query.py index b188792186673..4b97d1df5f8cc 100644 --- a/posthog/api/test/test_insight_query.py +++ b/posthog/api/test/test_insight_query.py @@ -175,29 +175,6 @@ def test_cannot_save_invalid_persons_table_query_to_an_insight(self) -> None: expected_status=status.HTTP_201_CREATED, ) - def test_listing_insights_by_default_does_not_include_those_with_only_queries(self) -> None: - self.dashboard_api.create_insight({"name": "Insight with filters"}) - self.dashboard_api.create_insight( - { - "name": "Insight with persons table query", - "query": { - "kind": "DataTableNode", - "columns": ["person", "id", "created_at", "person.$delete"], - "source": { - "kind": "EventsQuery", - "select": ["*"], - }, - }, - }, - ) - - created_insights: list[Insight] = list(Insight.objects.all()) - assert len(created_insights) == 2 - - listed_insights = self.dashboard_api.list_insights(query_params={"include_query_insights": False}) - assert listed_insights["count"] == 1 - assert listed_insights["results"][0]["name"] == "Insight with filters" - def test_can_list_insights_including_those_with_only_queries(self) -> None: self.dashboard_api.create_insight({"name": "Insight with filters"}) self.dashboard_api.create_insight( @@ -217,5 +194,5 @@ def test_can_list_insights_including_those_with_only_queries(self) -> None: created_insights: list[Insight] = list(Insight.objects.all()) assert len(created_insights) == 2 - listed_insights = self.dashboard_api.list_insights(query_params={"include_query_insights": True}) + listed_insights = self.dashboard_api.list_insights() assert listed_insights["count"] == 2