From 7438d0443cfb7131f299b79e3fc7e88fa6a4e876 Mon Sep 17 00:00:00 2001
From: Michael Matloka <dev@twixes.com>
Date: Mon, 14 Mar 2022 13:04:36 +0100
Subject: [PATCH] chore(dashboards): Purge `dive-dashboards` (#8946)

* chore(dashboards): Purge `dive-dashboards`

* Update constants.tsx

* Update funnelLogic.test.ts
---
 frontend/src/lib/constants.tsx                |  1 -
 .../src/scenes/funnels/funnelLogic.test.ts    |  1 -
 frontend/src/types.ts                         |  1 -
 posthog/api/insight.py                        |  3 +--
 .../test/__snapshots__/test_dashboard.ambr    | 20 +++++++++----------
 posthog/models/insight.py                     |  3 ++-
 6 files changed, 13 insertions(+), 16 deletions(-)

diff --git a/frontend/src/lib/constants.tsx b/frontend/src/lib/constants.tsx
index 98115bdff3a67..1fc3f08e1cbf2 100644
--- a/frontend/src/lib/constants.tsx
+++ b/frontend/src/lib/constants.tsx
@@ -93,7 +93,6 @@ export const FEATURE_FLAGS = {
     NPS_PROMPT: '4562-nps', // owner: @paolodamico
     // Experiments / beta features
     INGESTION_GRID: 'ingestion-grid-exp-3', // owner: @kpthatsme
-    DIVE_DASHBOARDS: 'hackathon-dive-dashboards', // owner: @tiina303
     NEW_PATHS_UI_EDGE_WEIGHTS: 'new-paths-ui-edge-weights', // owner: @neilkakkar
     BREAKDOWN_BY_MULTIPLE_PROPERTIES: '938-breakdown-by-multiple-properties', // owner: @pauldambra
     FUNNELS_CUE_OPT_OUT: 'funnels-cue-opt-out-7301', // owner: @paolodamico
diff --git a/frontend/src/scenes/funnels/funnelLogic.test.ts b/frontend/src/scenes/funnels/funnelLogic.test.ts
index 3d059a8637513..ed62ed9340806 100644
--- a/frontend/src/scenes/funnels/funnelLogic.test.ts
+++ b/frontend/src/scenes/funnels/funnelLogic.test.ts
@@ -90,7 +90,6 @@ export const mockInsight = {
     order: null,
     deleted: false,
     dashboard: null,
-    dive_dashboard: null,
     layouts: {},
     color: null,
     last_refresh: null,
diff --git a/frontend/src/types.ts b/frontend/src/types.ts
index ff449cfae53d1..722743e7a1f28 100644
--- a/frontend/src/types.ts
+++ b/frontend/src/types.ts
@@ -687,7 +687,6 @@ export interface InsightModel {
     refreshing: boolean
     is_sample: boolean
     dashboard: number | null
-    dive_dashboard?: number
     result: any | null
     updated_at: string
     tags?: string[]
diff --git a/posthog/api/insight.py b/posthog/api/insight.py
index 6b3ac5f3a2fdf..7407e6816d714 100644
--- a/posthog/api/insight.py
+++ b/posthog/api/insight.py
@@ -103,7 +103,6 @@ class Meta:
             "order",
             "deleted",
             "dashboard",
-            "dive_dashboard",
             "layouts",
             "color",
             "last_refresh",
@@ -140,7 +139,7 @@ def create(self, validated_data: Dict, *args: Any, **kwargs: Any) -> Insight:
         validated_data.pop("last_refresh", None)  # last_refresh sometimes gets sent if dashboard_item is duplicated
         tags = validated_data.pop("tags", None)  # tags are created separately as global tag relationships
 
-        if not validated_data.get("dashboard", None) and not validated_data.get("dive_dashboard", None):
+        if not validated_data.get("dashboard", None):
             dashboard_item = Insight.objects.create(
                 team=team, created_by=request.user, last_modified_by=request.user, **validated_data
             )
diff --git a/posthog/api/test/__snapshots__/test_dashboard.ambr b/posthog/api/test/__snapshots__/test_dashboard.ambr
index 8a00af8bfebd0..4dd44d4e11e42 100644
--- a/posthog/api/test/__snapshots__/test_dashboard.ambr
+++ b/posthog/api/test/__snapshots__/test_dashboard.ambr
@@ -159,7 +159,6 @@
   '
   SELECT "posthog_dashboarditem"."id",
          "posthog_dashboarditem"."dashboard_id",
-         "posthog_dashboarditem"."dive_dashboard_id",
          "posthog_dashboarditem"."name",
          "posthog_dashboarditem"."derived_name",
          "posthog_dashboarditem"."description",
@@ -181,6 +180,7 @@
          "posthog_dashboarditem"."refresh_attempt",
          "posthog_dashboarditem"."last_modified_at",
          "posthog_dashboarditem"."last_modified_by_id",
+         "posthog_dashboarditem"."dive_dashboard_id",
          "posthog_dashboarditem"."updated_at"
   FROM "posthog_dashboarditem"
   WHERE (NOT "posthog_dashboarditem"."deleted"
@@ -196,7 +196,6 @@
   '
   SELECT "posthog_dashboarditem"."id",
          "posthog_dashboarditem"."dashboard_id",
-         "posthog_dashboarditem"."dive_dashboard_id",
          "posthog_dashboarditem"."name",
          "posthog_dashboarditem"."derived_name",
          "posthog_dashboarditem"."description",
@@ -218,6 +217,7 @@
          "posthog_dashboarditem"."refresh_attempt",
          "posthog_dashboarditem"."last_modified_at",
          "posthog_dashboarditem"."last_modified_by_id",
+         "posthog_dashboarditem"."dive_dashboard_id",
          "posthog_dashboarditem"."updated_at"
   FROM "posthog_dashboarditem"
   WHERE (NOT "posthog_dashboarditem"."deleted"
@@ -488,7 +488,6 @@
   '
   SELECT "posthog_dashboarditem"."id",
          "posthog_dashboarditem"."dashboard_id",
-         "posthog_dashboarditem"."dive_dashboard_id",
          "posthog_dashboarditem"."name",
          "posthog_dashboarditem"."derived_name",
          "posthog_dashboarditem"."description",
@@ -510,6 +509,7 @@
          "posthog_dashboarditem"."refresh_attempt",
          "posthog_dashboarditem"."last_modified_at",
          "posthog_dashboarditem"."last_modified_by_id",
+         "posthog_dashboarditem"."dive_dashboard_id",
          "posthog_dashboarditem"."updated_at"
   FROM "posthog_dashboarditem"
   WHERE ("posthog_dashboarditem"."dashboard_id" = 2
@@ -732,7 +732,6 @@
   '
   SELECT "posthog_dashboarditem"."id",
          "posthog_dashboarditem"."dashboard_id",
-         "posthog_dashboarditem"."dive_dashboard_id",
          "posthog_dashboarditem"."name",
          "posthog_dashboarditem"."derived_name",
          "posthog_dashboarditem"."description",
@@ -754,6 +753,7 @@
          "posthog_dashboarditem"."refresh_attempt",
          "posthog_dashboarditem"."last_modified_at",
          "posthog_dashboarditem"."last_modified_by_id",
+         "posthog_dashboarditem"."dive_dashboard_id",
          "posthog_dashboarditem"."updated_at"
   FROM "posthog_dashboarditem"
   WHERE (NOT "posthog_dashboarditem"."deleted"
@@ -876,7 +876,6 @@
   '
   SELECT "posthog_dashboarditem"."id",
          "posthog_dashboarditem"."dashboard_id",
-         "posthog_dashboarditem"."dive_dashboard_id",
          "posthog_dashboarditem"."name",
          "posthog_dashboarditem"."derived_name",
          "posthog_dashboarditem"."description",
@@ -898,6 +897,7 @@
          "posthog_dashboarditem"."refresh_attempt",
          "posthog_dashboarditem"."last_modified_at",
          "posthog_dashboarditem"."last_modified_by_id",
+         "posthog_dashboarditem"."dive_dashboard_id",
          "posthog_dashboarditem"."updated_at"
   FROM "posthog_dashboarditem"
   WHERE ("posthog_dashboarditem"."dashboard_id" = 2
@@ -1155,7 +1155,6 @@
   '
   SELECT "posthog_dashboarditem"."id",
          "posthog_dashboarditem"."dashboard_id",
-         "posthog_dashboarditem"."dive_dashboard_id",
          "posthog_dashboarditem"."name",
          "posthog_dashboarditem"."derived_name",
          "posthog_dashboarditem"."description",
@@ -1177,6 +1176,7 @@
          "posthog_dashboarditem"."refresh_attempt",
          "posthog_dashboarditem"."last_modified_at",
          "posthog_dashboarditem"."last_modified_by_id",
+         "posthog_dashboarditem"."dive_dashboard_id",
          "posthog_dashboarditem"."updated_at"
   FROM "posthog_dashboarditem"
   WHERE (NOT "posthog_dashboarditem"."deleted"
@@ -1415,7 +1415,6 @@
   '
   SELECT "posthog_dashboarditem"."id",
          "posthog_dashboarditem"."dashboard_id",
-         "posthog_dashboarditem"."dive_dashboard_id",
          "posthog_dashboarditem"."name",
          "posthog_dashboarditem"."derived_name",
          "posthog_dashboarditem"."description",
@@ -1437,6 +1436,7 @@
          "posthog_dashboarditem"."refresh_attempt",
          "posthog_dashboarditem"."last_modified_at",
          "posthog_dashboarditem"."last_modified_by_id",
+         "posthog_dashboarditem"."dive_dashboard_id",
          "posthog_dashboarditem"."updated_at"
   FROM "posthog_dashboarditem"
   WHERE ("posthog_dashboarditem"."dashboard_id" = 2
@@ -1700,7 +1700,6 @@
   '
   SELECT "posthog_dashboarditem"."id",
          "posthog_dashboarditem"."dashboard_id",
-         "posthog_dashboarditem"."dive_dashboard_id",
          "posthog_dashboarditem"."name",
          "posthog_dashboarditem"."derived_name",
          "posthog_dashboarditem"."description",
@@ -1722,6 +1721,7 @@
          "posthog_dashboarditem"."refresh_attempt",
          "posthog_dashboarditem"."last_modified_at",
          "posthog_dashboarditem"."last_modified_by_id",
+         "posthog_dashboarditem"."dive_dashboard_id",
          "posthog_dashboarditem"."updated_at"
   FROM "posthog_dashboarditem"
   WHERE ("posthog_dashboarditem"."dashboard_id" = 2
@@ -1936,7 +1936,6 @@
   '
   SELECT "posthog_dashboarditem"."id",
          "posthog_dashboarditem"."dashboard_id",
-         "posthog_dashboarditem"."dive_dashboard_id",
          "posthog_dashboarditem"."name",
          "posthog_dashboarditem"."derived_name",
          "posthog_dashboarditem"."description",
@@ -1958,6 +1957,7 @@
          "posthog_dashboarditem"."refresh_attempt",
          "posthog_dashboarditem"."last_modified_at",
          "posthog_dashboarditem"."last_modified_by_id",
+         "posthog_dashboarditem"."dive_dashboard_id",
          "posthog_dashboarditem"."updated_at"
   FROM "posthog_dashboarditem"
   WHERE (NOT "posthog_dashboarditem"."deleted"
@@ -2024,7 +2024,6 @@
   '
   SELECT "posthog_dashboarditem"."id",
          "posthog_dashboarditem"."dashboard_id",
-         "posthog_dashboarditem"."dive_dashboard_id",
          "posthog_dashboarditem"."name",
          "posthog_dashboarditem"."derived_name",
          "posthog_dashboarditem"."description",
@@ -2046,6 +2045,7 @@
          "posthog_dashboarditem"."refresh_attempt",
          "posthog_dashboarditem"."last_modified_at",
          "posthog_dashboarditem"."last_modified_by_id",
+         "posthog_dashboarditem"."dive_dashboard_id",
          "posthog_dashboarditem"."updated_at"
   FROM "posthog_dashboarditem"
   WHERE ("posthog_dashboarditem"."dashboard_id" = 2
diff --git a/posthog/models/insight.py b/posthog/models/insight.py
index ac2cd4f8474ed..e48a957e1fda6 100644
--- a/posthog/models/insight.py
+++ b/posthog/models/insight.py
@@ -28,7 +28,6 @@ class Insight(models.Model):
     dashboard: models.ForeignKey = models.ForeignKey(
         "Dashboard", related_name="items", on_delete=models.CASCADE, null=True, blank=True,
     )
-    dive_dashboard: models.ForeignKey = models.ForeignKey("Dashboard", on_delete=models.SET_NULL, null=True, blank=True)
     name: models.CharField = models.CharField(max_length=400, null=True, blank=True)
     derived_name: models.CharField = models.CharField(max_length=400, null=True, blank=True)
     description: models.CharField = models.CharField(max_length=400, null=True, blank=True)
@@ -57,6 +56,8 @@ class Insight(models.Model):
         "User", on_delete=models.SET_NULL, null=True, blank=True, related_name="modified_insights",
     )
 
+    # TODO: dive dashboards have never been shipped, but they still may be in the future
+    dive_dashboard: models.ForeignKey = models.ForeignKey("Dashboard", on_delete=models.SET_NULL, null=True, blank=True)
     # DEPRECATED: in practically all cases field `last_modified_at` should be used instead
     updated_at: models.DateTimeField = models.DateTimeField(auto_now=True)
     # DEPRECATED: use `display` property of the Filter object instead