diff --git a/dashboard/fixtures/dashboard_example_data.json.gz b/dashboard/fixtures/dashboard_example_data.json.gz index ac645e5c1..6073fb088 100644 Binary files a/dashboard/fixtures/dashboard_example_data.json.gz and b/dashboard/fixtures/dashboard_example_data.json.gz differ diff --git a/dashboard/fixtures/dashboard_production_metrics.json b/dashboard/fixtures/dashboard_production_metrics.json index 14dff7d40..a7be9046a 100644 --- a/dashboard/fixtures/dashboard_production_metrics.json +++ b/dashboard/fixtures/dashboard_production_metrics.json @@ -11,7 +11,7 @@ "model": "dashboard.category", "pk": 2, "fields": { - "name": "Patches", + "name": "Pull requests", "position": 2 } }, @@ -51,7 +51,7 @@ "model": "dashboard.tracticketmetric", "pk": 2, "fields": { - "name": "Patches needing review", + "name": "PRs needing review", "slug": "patches", "category": 2, "position": 3, @@ -67,7 +67,7 @@ "model": "dashboard.tracticketmetric", "pk": 3, "fields": { - "name": "Doc. patches needing review", + "name": "Doc. PRs needing review", "slug": "doc-patches", "category": 2, "position": 4, @@ -165,7 +165,7 @@ "fields": { "name": "\"Easy\" tickets", "slug": "easy-tickets", - "category": 2, + "category": 4, "position": 1, "show_on_dashboard": true, "show_sparkline": true, diff --git a/dashboard/fixtures/dashboard_test_data.json b/dashboard/fixtures/dashboard_test_data.json index e398fd78d..384fbfe49 100644 --- a/dashboard/fixtures/dashboard_test_data.json +++ b/dashboard/fixtures/dashboard_test_data.json @@ -10,7 +10,7 @@ { "fields": { "position": 2, - "name": "Patches" + "name": "Pull requests" }, "model": "dashboard.category", "pk": 2 @@ -51,7 +51,7 @@ "fields": { "category": 2, "show_on_dashboard": true, - "name": "Patches needing review", + "name": "PRs needing review", "period": "instant", "show_sparkline": true, "query": "status=!closed&needs_better_patch=0&needs_tests=0&needs_docs=0&has_patch=1&stage=Accepted", @@ -67,7 +67,7 @@ "fields": { "category": 2, "show_on_dashboard": true, - "name": "Doc. patches needing review", + "name": "Doc. PRs needing review", "period": "instant", "show_sparkline": true, "query": "status=!closed&needs_better_patch=0&component=Documentation&needs_tests=0&needs_docs=0&has_patch=1&stage=Accepted", @@ -161,7 +161,7 @@ }, { "fields": { - "category": 2, + "category": 4, "show_on_dashboard": true, "name": "\"Easy\" tickets", "period": "instant", diff --git a/dashboard/migrations/0003_rename_patch_to_pr.py b/dashboard/migrations/0003_rename_patch_to_pr.py new file mode 100644 index 000000000..80de6c17d --- /dev/null +++ b/dashboard/migrations/0003_rename_patch_to_pr.py @@ -0,0 +1,71 @@ +from django.db import migrations + +CATEGORY_RENAMES = { + # old name: new name + "Patches": "Pull requests", +} + +TRACMETRIC_RENAMES = { + # old name: new name + "Patches needing review": "Tickets with PRs needing review", + "Doc. patches needing review": "Doc. tickets with PRs needing review", +} + +CATEGORY_CHANGES = { + # Metric name: (old category, new category) + "\"Easy\" tickets": ("Patches", "Accepted tickets by type"), +} + + +def _reverse(d): + """ + Reverse the given dict (values become keys and vice-versa). + """ + return {v: k for k, v in d.items()} + + +def rename(apps, schema_editor): + Category = apps.get_model("dashboard", "Category") + TracTicketMetric = apps.get_model("dashboard", "TracTicketMetric") + + for metric, (old, new) in CATEGORY_CHANGES.items(): + new_category = Category.objects.filter(name=new).first() + if not new_category: + continue + metrics = TracTicketMetric.objects.filter(name=metric, category__name=old) + metrics.update(category=new_category) + + for old, new in CATEGORY_RENAMES.items(): + Category.objects.filter(name=old).update(name=new) + + for old, new in TRACMETRIC_RENAMES.items(): + TracTicketMetric.objects.filter(name=old).update(name=new) + + +def rename_backwards(apps, schema_editor): + Category = apps.get_model("dashboard", "Category") + TracTicketMetric = apps.get_model("dashboard", "TracTicketMetric") + + for old, new in _reverse(TRACMETRIC_RENAMES).items(): + TracTicketMetric.objects.filter(name=old).update(name=new) + + for old, new in _reverse(CATEGORY_RENAMES).items(): + Category.objects.filter(name=old).update(name=new) + + for metric, (new, old) in CATEGORY_CHANGES.items(): + new_category = Category.objects.filter(name=new).first() + if not new_category: + continue + metrics = TracTicketMetric.objects.filter(name=metric, category__name=old) + metrics.update(category=new_category) + + +class Migration(migrations.Migration): + + dependencies = [ + ('dashboard', '0002_delete_rssfeedmetric_create_githubsearchcountmetric'), + ] + + operations = [ + migrations.RunPython(rename, rename_backwards), + ]