Skip to content

Backend toon migration#1613

Merged
Artuomka merged 4 commits into
mainfrom
backend_toon_migration
Feb 19, 2026
Merged

Backend toon migration#1613
Artuomka merged 4 commits into
mainfrom
backend_toon_migration

Conversation

@Artuomka

Copy link
Copy Markdown
Collaborator

No description provided.

- Added FindAllSavedDbQueriesUseCase to retrieve all saved database queries.
- Introduced FindSavedDbQueryUseCase for fetching a specific saved query by ID.
- Created panel-use-cases.interface.ts to define interfaces for panel operations.
- Developed TestDbQueryUseCase to test database queries with safety checks.
- Implemented UpdateSavedDbQueryUseCase for updating existing saved queries.
- Added utility functions for building DTOs and checking query safety.
- Created migration to rename visualization entities in the database.
- Added end-to-end tests for AI-generated dashboard widgets, including safety checks for queries.
Copilot AI review requested due to automatic review settings February 19, 2026 10:28
@Artuomka Artuomka enabled auto-merge February 19, 2026 10:28

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This pull request implements a significant refactoring that renames core visualization entities in the backend codebase. The main changes involve:

  1. Database Migration: Renames saved_db_query table to panel and dashboard_widget table to panel_position, along with column renames (widget_typepanel_type, widget_optionspanel_options)

  2. Entity Refactoring: Updates all entity classes, repositories, DTOs, data structures, use cases, and controllers to reflect the new naming convention

  3. New AI Feature: Adds AI-powered widget generation capability that creates dashboard widgets from natural language descriptions

Changes:

  • Database migration with proper up/down functions for table and column renames
  • Comprehensive entity, repository, and use case refactoring from "saved-db-query" to "panel" and "dashboard-widget" to "panel-position"
  • New AI widget generation endpoint with query safety validation
  • Query safety utility supporting multiple database types (SQL, MongoDB, Elasticsearch, Redis, DynamoDB)
  • New end-to-end tests for AI widget generation
  • Updates to global database context and module imports

Reviewed changes

Copilot reviewed 58 out of 67 changed files in this pull request and generated 2 comments.

Show a summary per file
File Description
backend/src/migrations/1771344994001-RenameVisualisationEntities.ts Database migration renaming tables and columns
backend/src/entities/visualizations/panel/* Refactored panel entity, DTOs, use cases, and repository (formerly saved-db-query)
backend/src/entities/visualizations/panel-position/* Refactored panel-position entity, DTOs, use cases, and repository (formerly dashboard-widget)
backend/src/entities/visualizations/panel/utils/check-query-is-safe.util.ts New comprehensive query safety validation for multiple database types
backend/src/entities/visualizations/panel-position/use-cases/generate-panel-position-with-ai.use.case.ts New AI-powered widget generation feature
backend/src/common/application/global-database-context.ts Updated repository accessors to use new naming
backend/src/common/application/global-database-context.interface.ts Updated interface with new repository names
backend/src/entities/connection/connection.entity.ts Updated relationship from saved_db_queries to panels
backend/src/entities/visualizations/dashboard/* Updated references to use new entity names
backend/src/app.module.ts Updated module imports to use PanelModule and PanelPositionModule
backend/test/ava-tests/saas-tests/saved-database-queries-e2e.test.ts Updated test imports to use FoundPanelDto
backend/test/ava-tests/saas-tests/dashboard-ai-widget-e2e.test.ts New comprehensive end-to-end tests for AI widget generation
backend/src/entities/table-categories/use-cases/find-table-categories-with-tables.use.case.ts Commented out table sorting logic
Comments suppressed due to low confidence (8)

backend/src/entities/visualizations/panel/use-cases/delete-panel.use.case.ts:14

  • The class name DeleteSavedDbQueryUseCase should be renamed to DeletePanelUseCase to match the file name delete-panel.use.case.ts and align with the migration from "saved-db-query" to "panel" terminology.
    backend/src/entities/visualizations/panel/use-cases/update-panel.use.case.ts:15
  • The class name UpdateSavedDbQueryUseCase should be renamed to UpdatePanelUseCase to be consistent with the file name update-panel.use.case.ts and the migration from "saved-db-query" to "panel" terminology.
    backend/src/entities/visualizations/panel-position/use-cases/update-panel-position.use.case.ts:14
  • The class name UpdateDashboardWidgetUseCase should be renamed to UpdatePanelPositionUseCase to match the file name update-panel-position.use.case.ts and align with the migration from "dashboard-widget" to "panel-position" terminology.
    backend/src/entities/visualizations/panel/panel.controller.ts:56
  • The class name SavedDbQueryController should be renamed to PanelController to match the file name panel.controller.ts and align with the migration from "saved-db-query" to "panel" terminology throughout the codebase.
    backend/src/entities/visualizations/panel-position/panel-position.controller.ts:45
  • The class name DashboardWidgetController should be renamed to PanelPositionController to match the file name panel-position.controller.ts and align with the migration from "dashboard-widget" to "panel-position" terminology throughout the codebase.
    backend/src/entities/visualizations/panel/use-cases/find-panel.use.case.ts:12
  • The class name FindSavedDbQueryUseCase should be renamed to FindPanelUseCase to be consistent with the file name and the migration from "saved-db-query" to "panel" terminology. This inconsistency could cause confusion for developers working with this codebase.
    backend/src/entities/visualizations/panel/use-cases/find-all-panels.use.case.ts:14
  • The class name FindAllSavedDbQueriesUseCase should be renamed to FindAllPanelsUseCase to align with the migration from "saved-db-query" to "panel" terminology and match the file name find-all-panels.use.case.ts.
    backend/src/entities/visualizations/panel/dto/found-saved-db-query.dto.ts:4
  • The file name found-saved-db-query.dto.ts should be renamed to found-panel.dto.ts to match the class it contains (FoundPanelDto) and align with the migration from "saved-db-query" to "panel" terminology. This would improve code organization and make it easier for developers to locate the correct file.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment on lines +93 to 98
// const sortedTables = tablesRO.sort((tableRO1, tableRO2) => {
// const name1 = tableRO1.display_name || tableRO1.table;
// const name2 = tableRO2.display_name || tableRO2.table;
// return name1.localeCompare(name2);
// });

Copilot AI Feb 19, 2026

Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The commented-out table sorting logic should either be removed or uncommented with an explanation. Leaving commented code without context reduces code maintainability and clarity. If this sorting was intentionally disabled, a comment explaining why would be helpful.

Suggested change
// const sortedTables = tablesRO.sort((tableRO1, tableRO2) => {
// const name1 = tableRO1.display_name || tableRO1.table;
// const name2 = tableRO2.display_name || tableRO2.table;
// return name1.localeCompare(name2);
// });

Copilot uses AI. Check for mistakes.
Comment on lines +1 to +24
import { PanelEntity } from '../panel.entity.js';
import { IPanelRepository } from './saved-db-query.repository.interface.js';

export const panelCustomRepositoryExtension: IPanelRepository = {
async findAllQueriesByConnectionId(connectionId: string): Promise<PanelEntity[]> {
const qb = this.createQueryBuilder('panel');
qb.where('panel.connection_id = :connectionId', { connectionId });
qb.orderBy('panel.created_at', 'DESC');
return await qb.getMany();
},

async findQueryById(queryId: string): Promise<PanelEntity | null> {
const qb = this.createQueryBuilder('panel');
qb.where('panel.id = :queryId', { queryId });
return await qb.getOne();
},

async findQueryByIdAndConnectionId(queryId: string, connectionId: string): Promise<PanelEntity | null> {
const qb = this.createQueryBuilder('panel');
qb.where('panel.id = :queryId', { queryId });
qb.andWhere('panel.connection_id = :connectionId', { connectionId });
return await qb.getOne();
},
};

Copilot AI Feb 19, 2026

Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The file names saved-db-query-custom-repository-extension.ts and saved-db-query.repository.interface.ts should be renamed to panel-custom-repository-extension.ts and panel.repository.interface.ts respectively to align with the migration from "saved-db-query" to "panel" terminology and maintain naming consistency across the repository layer.

Copilot uses AI. Check for mistakes.
@Artuomka Artuomka merged commit 5cd0c4a into main Feb 19, 2026
23 of 25 checks passed
@Artuomka Artuomka deleted the backend_toon_migration branch February 19, 2026 10:42
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants