feat: add chart_type to DashboardWidgetEntity and related DTOs for enhanced widget configuration#1521
Conversation
…hanced widget configuration
There was a problem hiding this comment.
Pull request overview
This pull request adds a new chart_type field to the DashboardWidgetEntity and propagates it through the entire data flow pipeline to support enhanced configuration for chart widgets.
Changes:
- Added database migration to create a nullable
chart_typevarchar column in thedashboard_widgettable - Updated entity, DTOs, data structures, use cases, controller, and utility functions to handle the new field
- Made the field optional/nullable across all layers to maintain backward compatibility
Reviewed changes
Copilot reviewed 11 out of 11 changed files in this pull request and generated 2 comments.
Show a summary per file
| File | Description |
|---|---|
| backend/src/migrations/1769087579873-AddChartTypeFieldIntoDashboardWidgetEntity.ts | Database migration to add chart_type column |
| backend/src/entities/visualizations/dashboard-widget/dashboard-widget.entity.ts | Added nullable chart_type column to entity |
| backend/src/entities/visualizations/dashboard-widget/dto/create-dashboard-widget.dto.ts | Added optional chart_type to creation DTO |
| backend/src/entities/visualizations/dashboard-widget/dto/update-dashboard-widget.dto.ts | Added optional chart_type to update DTO |
| backend/src/entities/visualizations/dashboard-widget/dto/found-dashboard-widget.dto.ts | Added nullable chart_type to response DTO |
| backend/src/entities/visualizations/dashboard-widget/data-structures/create-dashboard-widget.ds.ts | Added optional chart_type to creation data structure |
| backend/src/entities/visualizations/dashboard-widget/data-structures/update-dashboard-widget.ds.ts | Added optional chart_type to update data structure |
| backend/src/entities/visualizations/dashboard-widget/use-cases/create-dashboard-widget.use.case.ts | Handles chart_type during widget creation with null coalescing |
| backend/src/entities/visualizations/dashboard-widget/use-cases/update-dashboard-widget.use.case.ts | Handles chart_type during widget updates |
| backend/src/entities/visualizations/dashboard-widget/utils/build-found-dashboard-widget-dto.util.ts | Includes chart_type in DTO builder |
| backend/src/entities/visualizations/dashboard-widget/dashboard-widgets.controller.ts | Maps chart_type from DTOs to data structures |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
| foundWidget.widget_type = widget_type; | ||
| } | ||
| if (chart_type !== undefined) { | ||
| foundWidget.chart_type = chart_type; |
There was a problem hiding this comment.
The chart_type field handling in the update use case is inconsistent with how the entity expects nullable values. When chart_type is provided as an optional string in the DTO, it should be converted to null when empty or undefined (similar to how it's handled in the create use case with chart_type || null). Currently, if an empty string is passed, it will be stored as an empty string instead of null, which is inconsistent with the entity's nullable design and the create operation.
| foundWidget.chart_type = chart_type; | |
| foundWidget.chart_type = chart_type || null; |
|
|
||
| const newWidget = new DashboardWidgetEntity(); | ||
| newWidget.widget_type = widget_type; | ||
| newWidget.chart_type = chart_type || null; |
There was a problem hiding this comment.
The new chart_type field lacks test coverage. The existing dashboard widget e2e tests don't include verification of this field in widget creation, update, or retrieval operations. Consider adding test cases that verify chart_type is properly stored, retrieved, and updated, especially for widgets with widget_type 'chart'.
No description provided.