Fix DividendIncomeMini hidden for users with past dividends#175
Merged
Conversation
The server's `/dividends/chart_data` returns 24 buckets per currency: 12 past + 12 future. Past months carry `actual` (paid), future ones carry `projected` (forecasted from holdings). `slice(-12)` grabbed the wrong half — the *last* 12 entries are the projection window (current month + 11 forward). Their `actual` is mostly `null`, so the "total of actual values" sat at 0 unless the user happened to have a payment in the current month. Result: users with months of dividend history saw the whole card hidden. Filter past-only entries (`actual !== null`) and take the last 12 of those — robust to wider server windows like `range=full`. This is the data the "Last 12 months" sparkline already advertises. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
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.
Reported in prod after #174 merged.
Bug
User has several recorded dividends but the
DividendIncomeMinicard never renders on the dashboard.Root cause
/dividends/chart_datareturns 24 buckets per currency: 12 past + 12 future. Past months carryactual(paid), future months carryprojected(forecasted from holdings).My code did
buckets.slice(-12)— grabbing the last 12 entries, which is the future half (current month + 11 forward). Theiractualis mostlynull, so the empty-state guardtotal === 0fired and the card hid itself, unless the user happened to have a payment in the current month.Fix
Filter to past-only entries (
actual !== null) and take the last 12. Robust to wider server windows (e.g.range=fullopens the window further).Test plan
npx tsc --noEmit— cleanDividendIncomeMinirenders with this-month total + 12-bar sparkline🤖 Generated with Claude Code