Skip to content

Conversation

@ehconitin
Copy link
Contributor

@ehconitin ehconitin commented Nov 14, 2025

Context -

  • refactoring v1 and v2 seeds to test v2 dashboard flag both on and off
    Right now, the db reset command fails if the feature flag is off

  • whenever there is a groupBy field -- we should add a default groupMode - we already do that on the front -- but implementing the same on server so that api users get the same response

This is also the reason why the second seed on dashboards lags a lot -- because on that particular dashboard's widget -- we set groupBy but no groupMode (in seeding util) -- and the effect of limiting the bars to fifty runs depending on the groupMode

@greptile-apps
Copy link
Contributor

greptile-apps bot commented Nov 14, 2025

Greptile Overview

Greptile Summary

Separated v1 and v2 dashboard seed data and added default stacking mode for charts with secondary grouping.

  • Moved v2-specific dashboard widgets (LINE, PIE, GAUGE charts) to a new dedicated file get-page-layout-widget-data-seeds-v2.util.ts
  • Added automatic default values in validation: groupMode defaults to STACKED for bar charts and isStacked defaults to true for line charts when secondaryAxisGroupByFieldMetadataId is present but the mode is undefined
  • Updated seed generation to conditionally include v2 widgets based on isDashboardV2Enabled feature flag
  • Aligns backend defaults with frontend behavior where getEffectiveGroupMode returns 'stacked' as default and LINE_CHART_IS_STACKED_DEFAULT is true

Confidence Score: 5/5

  • This PR is safe to merge with no significant risks
  • The changes are well-structured: (1) seed data separation follows clean architecture principles, (2) default values align with existing frontend behavior where getEffectiveGroupMode and LINE_CHART_IS_STACKED_DEFAULT already default to stacked/true, (3) feature flag gating ensures backward compatibility, (4) no breaking changes to existing APIs or data structures
  • No files require special attention

Important Files Changed

File Analysis

Filename Score Overview
packages/twenty-server/src/engine/core-modules/page-layout/utils/validate-and-transform-widget-configuration.util.ts 5/5 Added default groupMode (STACKED) for bar charts and isStacked (true) for line charts when secondaryAxisGroupByFieldMetadataId is present but the mode is undefined
packages/twenty-server/src/engine/workspace-manager/dev-seeder/core/utils/get-page-layout-widget-data-seeds-v2.util.ts 5/5 New file containing v2-specific dashboard widget seeds (LINE, PIE, GAUGE charts) separated from v1 seeds
packages/twenty-server/src/engine/workspace-manager/dev-seeder/core/utils/get-page-layout-widget-data-seeds.util.ts 5/5 Removed v2 widgets from v1 seeds, added isDashboardV2Enabled parameter, conditionally includes v2 seeds based on feature flag
packages/twenty-server/src/engine/workspace-manager/dev-seeder/core/utils/seed-page-layout-widgets.util.ts 5/5 Added isDashboardV2Enabled parameter and passed it to getPageLayoutWidgetDataSeeds function

Sequence Diagram

sequenceDiagram
    participant Client as API Client
    participant Seeder as DevSeederService
    participant SeedUtil as seedPageLayoutWidgets
    participant GetSeeds as getPageLayoutWidgetDataSeeds
    participant GetSeedsV2 as getPageLayoutWidgetDataSeedsV2
    participant Validator as validateAndTransformWidgetConfiguration

    Client->>Seeder: Request seed data (isDashboardV2Enabled)
    Seeder->>SeedUtil: seedPageLayoutWidgets(workspaceId, objectMetadata, isDashboardV2Enabled)
    SeedUtil->>GetSeeds: getPageLayoutWidgetDataSeeds(workspaceId, objectMetadata, isDashboardV2Enabled)
    
    alt isDashboardV2Enabled = false
        GetSeeds->>GetSeeds: Return v1 widgets only
    else isDashboardV2Enabled = true
        GetSeeds->>GetSeedsV2: getPageLayoutWidgetDataSeedsV2(workspaceId, objectMetadata)
        GetSeedsV2-->>GetSeeds: Return v2 widgets (LINE, PIE, GAUGE)
        GetSeeds->>GetSeeds: Combine v1 + v2 widgets
    end
    
    GetSeeds-->>SeedUtil: Return combined widget seeds
    
    loop For each widget
        SeedUtil->>Validator: validateAndTransformWidgetConfiguration(type, config, isDashboardV2Enabled)
        
        alt Widget has secondaryAxisGroupByFieldMetadataId
            alt BarChart && groupMode undefined
                Validator->>Validator: Set groupMode = STACKED
            else LineChart && isStacked undefined
                Validator->>Validator: Set isStacked = true
            end
        end
        
        Validator-->>SeedUtil: Return validated configuration
    end
    
    SeedUtil->>SeedUtil: Insert widgets into database
    SeedUtil-->>Seeder: Seeding complete
    Seeder-->>Client: Success
Loading

Copy link
Contributor

@greptile-apps greptile-apps bot left a comment

Choose a reason for hiding this comment

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

4 files reviewed, no comments

Edit Code Review Agent Settings | Greptile

@github-actions
Copy link
Contributor

github-actions bot commented Nov 14, 2025

🚀 Preview Environment Ready!

Your preview environment is available at: http://bore.pub:54160

This environment will automatically shut down when the PR is closed or after 5 hours.

@lucasbordeau lucasbordeau force-pushed the fix-V2-Dashboards-seeds branch from 3d4cc34 to 70df123 Compare November 14, 2025 17:18
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants