fix(charts): prevent cross-year day bucket collisions in History and Dashboard (#29, #47) - #88
Open
ghzhost wants to merge 1 commit into
Open
Conversation
…Dashboard (StellarSend#29, StellarSend#47) - Extract shared chart aggregation utilities to src/utils/chart.ts (getHistoryChartData and getActivityChartData). - Key day buckets using normalized UTC YYYY-MM-DD keys so transactions on the same month/day in different years never collide. - Keep locale-formatted display strings ('MMM D') for chart axes and tooltips. - Add comprehensive test suite in src/utils/chart.test.ts validating cross-year separation and metric aggregations. - Fixes StellarSend#29 and resolves StellarSend#47 duplication.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Description
This PR fixes issue #29 (and resolves duplicate aggregation logic from #47) where transactions on the same month and day in different calendar years collided and summed into the same 30-day / 7-day chart buckets.
Root Cause
Previously,
History.tsx(HistoryChart) andDashboard.tsx(ActivityChart) built bucket keys using only the formatted locale month and day string:When historical data spanned multiple years or occurred around year boundaries, transactions from an earlier year with matching month/day (e.g.,
2025-08-15vs2026-08-15) matcheddays[key]and incorrectly aggregated into the current window's bucket.Solution
src/utils/chart.ts:getHistoryChartData(transactions, now)getActivityChartData(transactions, now)YYYY-MM-DD(toUtcDateKey(date)), preventing cross-year key collisions while preserving formattedMMM Ddisplay labels for chart axes and tooltips.src/utils/chart.test.tscovering cross-year isolation, 30-day and 7-day window sizes, and accurate volume / fee calculation.Closes #29
Resolves #47