cleanup: remove root-level layout_config and components from Dashboar…#1360
cleanup: remove root-level layout_config and components from Dashboar…#1360NaveenCode wants to merge 1 commit into
Conversation
…d (DALGO-1296) - Drop layout_config and components columns from Dashboard model (migration 0161) - Remove fields from DashboardResponse and FrozenDashboardConfig schemas - Update report_service, dashboard_service, chart_service, and duplicate API to iterate tabs - Add cleanup_frozen_dashboard_root_fields management command for ReportSnapshot JSON cleanup - Delete obsolete migrate_dashboards_to_tabs and migrate_report_snapshots_to_tabs commands - Update all test fixtures and assertions to use tabs structure
WalkthroughThis pull request completes the migration from a flat ChangesTab-Based Dashboard Structure Refactor
Estimated code review effort🎯 4 (Complex) | ⏱️ ~60 minutes Possibly related PRs
Suggested reviewers
🚥 Pre-merge checks | ✅ 5✅ Passed checks (5 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches📝 Generate docstrings
🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
Codecov Report❌ Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## main #1360 +/- ##
==========================================
+ Coverage 58.66% 58.72% +0.05%
==========================================
Files 132 132
Lines 15690 15653 -37
==========================================
- Hits 9205 9192 -13
+ Misses 6485 6461 -24 ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
There was a problem hiding this comment.
Actionable comments posted: 2
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
Inline comments:
In `@ddpui/services/dashboard_service.py`:
- Around line 1053-1056: The component-validation loop is currently outside the
"for tab in dashboard.tabs or []" loop causing only the last tab's components to
be validated; move the loop that iterates over components (the "for
component_id, component_config in components.items():" block) inside the tab
loop so each tab's components are validated, ensure "components =
tab.get('components') or {}" is set per tab before that inner loop, and keep
using the same identifiers (components, component_id, component_config,
component_type) to preserve existing logic.
In `@ddpui/tests/models/test_dashboard_models.py`:
- Line 145: The fixture uses a non-production chart component shape ("chart-1":
{"type": "chart", "chart_id": 1}); update the component to match the tab
component contract by replacing the root chart_id with a config object using
config.chartId (e.g., under the "chart-1" component keep "type": "chart" and add
"config": {"chartId": 1}) so tests reflect the real production schema used by
services.
🪄 Autofix (Beta)
Fix all unresolved CodeRabbit comments on this PR:
- Push a commit to this branch (recommended)
- Create a new PR with the fixes
ℹ️ Review info
⚙️ Run configuration
Configuration used: Organization UI
Review profile: CHILL
Plan: Pro
Run ID: 3504812d-f6fe-47e2-9dff-76ce875ea57f
📒 Files selected for processing (20)
ddpui/api/dashboard_native_api.pyddpui/core/reports/report_service.pyddpui/management/commands/cleanup_frozen_dashboard_root_fields.pyddpui/management/commands/migrate_dashboards_to_tabs.pyddpui/management/commands/migrate_report_snapshots_to_tabs.pyddpui/migrations/0161_remove_dashboard_root_layout_components.pyddpui/models/dashboard.pyddpui/schemas/dashboard_schema.pyddpui/schemas/report_schema.pyddpui/services/chart_service.pyddpui/services/dashboard_service.pyddpui/tests/api_tests/test_charts_api.pyddpui/tests/api_tests/test_dashboard_native_api.pyddpui/tests/api_tests/test_public_report_api.pyddpui/tests/api_tests/test_report_api.pyddpui/tests/core/reports/test_report_service.pyddpui/tests/models/test_dashboard_models.pyddpui/tests/schema_tests/test_dashboard_schema.pyddpui/tests/services/test_chart_service.pyddpui/tests/services/test_dashboard_service.py
💤 Files with no reviewable changes (9)
- ddpui/management/commands/migrate_report_snapshots_to_tabs.py
- ddpui/models/dashboard.py
- ddpui/schemas/report_schema.py
- ddpui/management/commands/migrate_dashboards_to_tabs.py
- ddpui/schemas/dashboard_schema.py
- ddpui/api/dashboard_native_api.py
- ddpui/tests/api_tests/test_dashboard_native_api.py
- ddpui/tests/schema_tests/test_dashboard_schema.py
- ddpui/tests/services/test_dashboard_service.py
| for tab in dashboard.tabs or []: | ||
| components = tab.get("components") or {} | ||
| for component_id, component_config in components.items(): | ||
| component_type = component_config.get("type") |
There was a problem hiding this comment.
Validate components inside each tab loop, not only the last tab.
On Line 1055, the component-validation loop is outside the for tab in dashboard.tabs block, so only the final tab’s components are checked.
Proposed fix
- for tab in dashboard.tabs or []:
- components = tab.get("components") or {}
- for component_id, component_config in components.items():
- component_type = component_config.get("type")
-
- if not component_type:
- errors.append(f"Component {component_id} has no type specified")
- continue
-
- if component_type not in [ct.value for ct in DashboardComponentType]:
- errors.append(f"Component {component_id} has invalid type: {component_type}")
-
- # Validate chart components
- if component_type == DashboardComponentType.CHART.value:
- config = component_config.get("config", {})
- if not config.get("chartId"):
- errors.append(f"Chart component {component_id} has no chartId")
+ for tab in dashboard.tabs or []:
+ components = tab.get("components") or {}
+ for component_id, component_config in components.items():
+ component_type = component_config.get("type")
+
+ if not component_type:
+ errors.append(f"Component {component_id} has no type specified")
+ continue
+
+ if component_type not in [ct.value for ct in DashboardComponentType]:
+ errors.append(f"Component {component_id} has invalid type: {component_type}")
+
+ # Validate chart components
+ if component_type == DashboardComponentType.CHART.value:
+ config = component_config.get("config", {})
+ if not config.get("chartId"):
+ errors.append(f"Chart component {component_id} has no chartId")📝 Committable suggestion
‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.
| for tab in dashboard.tabs or []: | |
| components = tab.get("components") or {} | |
| for component_id, component_config in components.items(): | |
| component_type = component_config.get("type") | |
| for tab in dashboard.tabs or []: | |
| components = tab.get("components") or {} | |
| for component_id, component_config in components.items(): | |
| component_type = component_config.get("type") | |
| if not component_type: | |
| errors.append(f"Component {component_id} has no type specified") | |
| continue | |
| if component_type not in [ct.value for ct in DashboardComponentType]: | |
| errors.append(f"Component {component_id} has invalid type: {component_type}") | |
| # Validate chart components | |
| if component_type == DashboardComponentType.CHART.value: | |
| config = component_config.get("config", {}) | |
| if not config.get("chartId"): | |
| errors.append(f"Chart component {component_id} has no chartId") |
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
In `@ddpui/services/dashboard_service.py` around lines 1053 - 1056, The
component-validation loop is currently outside the "for tab in dashboard.tabs or
[]" loop causing only the last tab's components to be validated; move the loop
that iterates over components (the "for component_id, component_config in
components.items():" block) inside the tab loop so each tab's components are
validated, ensure "components = tab.get('components') or {}" is set per tab
before that inner loop, and keep using the same identifiers (components,
component_id, component_config, component_type) to preserve existing logic.
| "id": "tab-1", | ||
| "title": "Tab 1", | ||
| "layout_config": [{"i": "chart-1", "x": 0, "y": 0, "w": 6, "h": 4}], | ||
| "components": {"chart-1": {"type": "chart", "chart_id": 1}}, |
There was a problem hiding this comment.
Use the same chart component schema as production (config.chartId).
This fixture uses chart_id at the component root, which does not match the tab component contract used by services.
Proposed fix
- "components": {"chart-1": {"type": "chart", "chart_id": 1}},
+ "components": {"chart-1": {"type": "chart", "config": {"chartId": 1}}},📝 Committable suggestion
‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.
| "components": {"chart-1": {"type": "chart", "chart_id": 1}}, | |
| "components": {"chart-1": {"type": "chart", "config": {"chartId": 1}}}, |
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
In `@ddpui/tests/models/test_dashboard_models.py` at line 145, The fixture uses a
non-production chart component shape ("chart-1": {"type": "chart", "chart_id":
1}); update the component to match the tab component contract by replacing the
root chart_id with a config object using config.chartId (e.g., under the
"chart-1" component keep "type": "chart" and add "config": {"chartId": 1}) so
tests reflect the real production schema used by services.
Summary
layout_configandcomponentsfields from the Dashboard systemdashboard.tabs[].layout_configanddashboard.tabs[].componentscleanup_frozen_dashboard_root_fieldsmanagement command to clean up existing ReportSnapshot JSON blobsMigration steps (on deploy)
python manage.py cleanup_frozen_dashboard_root_fieldspython manage.py migrate ddpui 0161Test plan
uv run pytest ddpui/tests/ --ignore=ddpui/tests/integration_tests)layout_config/componentsin API responseSummary by CodeRabbit