Skip to content

Commit 4e5aa60

Browse files
committed
Revert "fix(dashboard-tiles): migrate doubly stringified layouts correctly (#9497)"
This reverts commit 2d49394.
1 parent 2d49394 commit 4e5aa60

File tree

5 files changed

+5
-147
lines changed

5 files changed

+5
-147
lines changed

posthog/api/dashboard.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -196,7 +196,6 @@ def get_items(self, dashboard: Dashboard):
196196
insight = tile.insight
197197
layouts = tile.layouts
198198
# workaround because DashboardTiles are saving JSON as a string :/
199-
# TODO remove this after migration 0228 has been applied
200199
if isinstance(layouts, str):
201200
layouts = json.loads(layouts)
202201

posthog/migrations/0227_add_dashboard_tiles.py

Lines changed: 1 addition & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
11
# Generated by Django 3.2.12 on 2022-04-08 11:13
2-
import json
32

43
import structlog
54
from django.db import connection, migrations, models
@@ -35,15 +34,7 @@ def migrate_dashboard_insight_relations(apps, _) -> None:
3534
if not page:
3635
break
3736
DashboardTile.objects.bulk_create(
38-
[
39-
DashboardTile(
40-
insight_id=row[0],
41-
dashboard_id=row[1],
42-
layouts=json.loads(row[2]) if row[2] is not None else {},
43-
color=row[3],
44-
)
45-
for row in page
46-
],
37+
[DashboardTile(insight_id=row[0], dashboard_id=row[1], layouts=row[2], color=row[3]) for row in page],
4738
ignore_conflicts=True,
4839
)
4940
count += len(page)

posthog/migrations/0228_fix_tile_layouts.py

Lines changed: 0 additions & 64 deletions
This file was deleted.

posthog/test/test_migration_0227.py

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
import json
2+
13
from posthog.test.base import TestMigrations
24

35

@@ -59,11 +61,11 @@ def test_migrate_to_create_tiles(self):
5961
self.assertEqual(DashboardTile.objects.filter(dashboard__name="d2").count(), 2)
6062
blue_tile = DashboardTile.objects.get(dashboard__name="d2", insight__name="blue")
6163
self.assertEqual(blue_tile.color, "blue")
62-
self.assertEqual(blue_tile.layouts, {"some": "content"})
64+
self.assertEqual(blue_tile.layouts, json.dumps({"some": "content"}))
6365

6466
red_tile = DashboardTile.objects.get(dashboard__name="d2", insight__name="red")
6567
self.assertEqual(red_tile.color, "red")
66-
self.assertEqual(red_tile.layouts, {"some": "different content"})
68+
self.assertEqual(red_tile.layouts, json.dumps({"some": "different content"}))
6769

6870
# CASE 3:
6971
self.assertEqual(DashboardTile.objects.filter(dashboard__name="d3").count(), 0)

posthog/test/test_migration_0228.py

Lines changed: 0 additions & 70 deletions
This file was deleted.

0 commit comments

Comments
 (0)