Skip to content

Rewrite StatisticPage with factual date-range analytics and KPI sections#47

Open
IanTheMitten wants to merge 2 commits into
mainfrom
codex/refactor-statisticpage-component
Open

Rewrite StatisticPage with factual date-range analytics and KPI sections#47
IanTheMitten wants to merge 2 commits into
mainfrom
codex/refactor-statisticpage-component

Conversation

@IanTheMitten

Copy link
Copy Markdown
Owner

Motivation

  • Provide factual, non-sampled analytics driven by a standard date-range model (today, thisWeek, thisMonth, allTime, custom) so metric values reflect the selected boundaries.
  • Centralize transaction filtering so every statistic is computed from the same filteredTransactions source and keep selectedPeriodId for period drill-downs.
  • Surface high-level KPIs and factual sections (weekday, time-period, products, days, customers) for easier operational insight.

Description

  • Replaced the sampling model and sampling UI with a simple date-range selector implemented on the page and a StatisticDateRange type including today, thisWeek, thisMonth, allTime, and custom.
  • Derived filteredTransactions once with getDateBounds(...) and used it across all computed analytics including totalRevenue, unitsSold, transactionCount, avgBasketSize, weekday totals, time-period totals, top products, best days, and top customers.
  • Added a KPI row rendering Total Revenue, Units Sold, Transactions, and Avg Basket Size.
  • Reorganized the page into factual sections: weekday revenue chart, time-period revenue chart with clickable bars (keeps selectedPeriodId drill-down), selected-period running revenue chart, top products table, best days table, and top customers table.
  • Removed sampling-related state/props and imports (samplingSeed, sampled modes/options, WeekdayRevenueBarChart, TimePeriodRevenueBarChart, TimePeriodCumulativeLine, ProductAverageRevenueTable, and analyticsSampling usages) and adopted inline chart/table rendering driven by filteredTransactions.

Testing

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

Codex Task

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 4d7154c5c2

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

<tbody className="divide-y divide-gray-200">
{bestDays.map((row) => (
<tr key={row.dayKey}>
<td className="p-2 text-gray-900">{new Date(row.dayKey).toLocaleDateString('en-US')}</td>

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

P1 Badge Parse best-day keys as local dates

row.dayKey is produced in local calendar time (YYYY-MM-DD), but new Date(row.dayKey) parses that format as UTC; in US time zones this shifts many rows to the previous day (for example, 2026-04-01 can display as 3/31/2026). That makes the Best Days table show incorrect dates for the revenue/transaction totals it is summarizing, so users can act on the wrong day-level insight.

Useful? React with 👍 / 👎.

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