Skip to content

Extract shared weekday aggregation helpers and unify charts#53

Open
IanTheMitten wants to merge 1 commit into
mainfrom
codex/extract-shared-weekday-aggregation-helpers
Open

Extract shared weekday aggregation helpers and unify charts#53
IanTheMitten wants to merge 1 commit into
mainfrom
codex/extract-shared-weekday-aggregation-helpers

Conversation

@IanTheMitten

Copy link
Copy Markdown
Owner

Motivation

  • Remove duplicated weekday/date aggregation logic in budget and statistic codepaths to prevent divergence and make maintenance easier.
  • Provide a single source of truth for weekday revenue aggregation so both chart components and sampling utilities share identical behavior.

Description

  • Added src/components/analytics/sharedAggregation.ts with WEEKDAY_LABELS, getDayKey, parseDayKey, isWeekday, getWeekKey, getWeekdayRevenueByDate, and buildWeekdayAverageRevenueChartData to centralize weekday/date helpers and chart bucketing logic.
  • Updated src/components/budget/WeekdayRevenueBarChart.tsx and src/components/statistic/WeekdayRevenueBarChart.tsx to consume getWeekdayRevenueByDate and buildWeekdayAverageRevenueChartData from the shared module and added an import-comment near the imports to document the shared source for future maintainers.
  • Refactored src/components/budget/analyticsSampling.ts and src/components/statistic/analyticsSampling.ts to use the shared getDayKey, parseDayKey, getWeekKey, and getWeekdayRevenueByDate helpers instead of local duplicate implementations, preserving existing sampling APIs.
  • Kept chart presentation and public sampling APIs unchanged; each chart now calls the shared builder with page-specific sampled date arrays.

Testing

  • Ran the production build with npm run build, which completed successfully (Vite build completed without errors).

Codex Task

@chatgpt-codex-connector

Copy link
Copy Markdown

You have reached your Codex usage limits for code reviews. You can see your limits in the Codex usage dashboard.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant