Skip to content

Event Deltas: Extract utility functions and PropertyComparisonChart into separate files #1830

Closed

Description

@alex-fedotyev

Summary

Pure refactor — extract inline utility functions and the PropertyComparisonChart component from the monolithic DBDeltaChart.tsx (601 lines) into separate files. Zero behavior change. This establishes the file structure needed for the Event Deltas improvement series.

Problem

DBDeltaChart.tsx currently contains everything inline:

  • Data utility functions (flattenData, getPropertyStatistics, mergeValueStatisticsMaps)
  • The PropertyComparisonChart component and HDXBarChartTooltip
  • Layout constants (CHART_WIDTH, CHART_HEIGHT, CHART_GAP, PAGINATION_HEIGHT)
  • The main DBDeltaChart component with query logic

This violates the 300-line guideline in CLAUDE.md and makes it impossible to add features (filtering, scoring, sampling, highlights) without creating a massive single-file PR. Extracting into separate files enables parallel development of independent features.

Changes

New file: deltaChartUtils.ts

Move from DBDeltaChart.tsx:

  • flattenData() — recursive object/array flattener
  • getPropertyStatistics() — computes property/value percentage maps
  • mergeValueStatisticsMaps() — merges outlier/inlier value maps

No logic changes — exact same functions, just exported.

New file: PropertyComparisonChart.tsx

Move from DBDeltaChart.tsx:

  • PropertyComparisonChart component
  • HDXBarChartTooltip component
  • Layout constants: CHART_WIDTH, CHART_HEIGHT, CHART_GAP, PAGINATION_HEIGHT

No logic changes — exact same component and constants, just in their own file.

Modified: DBDeltaChart.tsx

  • Remove moved code (utilities, component, constants)
  • Add imports from deltaChartUtils and PropertyComparisonChart
  • All query logic, pagination, and rendering stay in place

Files

  • packages/app/src/components/deltaChartUtils.ts (NEW — ~160 lines moved)
  • packages/app/src/components/PropertyComparisonChart.tsx (NEW — ~120 lines moved)
  • packages/app/src/components/DBDeltaChart.tsx (MODIFIED — shrinks from ~601 to ~330 lines)

Dependencies

None — this is the foundational refactor that unblocks all Event Deltas feature PRs:

Test plan

  • Existing E2E tests pass (no behavior change)
  • Event Deltas comparison view works identically to before
  • No visual changes
  • tsc --noEmit passes (no type errors from moved code)

Review guidance

This is a move-only refactor. The reviewer should verify:

  1. Every function/component moved exists identically in the source file on main
  2. No logic was added, removed, or modified
  3. Imports in DBDeltaChart.tsx correctly reference the new files

Activity

  1. added a commit that references this issue on Mar 2, 2026
    d4aa600
  2. added a commit that references this issue on Apr 16, 2026
    4c27c7b
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

enhancementNew feature or request

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions