Add holdings sorting by total value descending with unit tests - #735
Open
Benedict315 wants to merge 2 commits into
Open
Add holdings sorting by total value descending with unit tests#735Benedict315 wants to merge 2 commits into
Benedict315 wants to merge 2 commits into
Conversation
- Add calculatePositionTotalValue utility to compute individual position value - Add sortHoldingsByTotalValue utility to sort holdings by total value descending - Apply sorting in LandingPage component before rendering holdings list - Add comprehensive unit tests covering all acceptance criteria: - Holdings rendered in descending total value order (1200, 500, 300) - Order updates when cache data changes (300 -> 1500 reorders to 1500, 1200, 500) - Stable secondary sort by creator ID for equal total values - Handles missing prices and zero quantities gracefully - Does not mutate original array - Sort applied before render via useMemo in LandingPage
|
@Benedict315 Great news! 🎉 Based on an automated assessment of this PR, the linked Wave issue(s) no longer count against your application limits. You can now already apply to more issues while waiting for a review of this PR. Keep up the great work! 🚀 |
Contributor
|
Fix CI |
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
Added holdings sorting functionality to display the highest-value positions at the top of the holdings list.
Implementation:
Added calculatePositionTotalValue() utility in portfolioValue.utils.ts to compute individual position total value (quantity × price)
Added sortHoldingsByTotalValue() utility to sort holdings by total value in descending order with stable secondary sort by creator ID
Applied sorting in LandingPage.tsx via useMemo before rendering the holdings list
Unit Tests (11 new tests):
Holdings rendered in descending total value order (1200, 500, 300)
Order updates when cache data changes (300 → 1500 reorders to 1500, 1200, 500)
Stable secondary sort by creator ID for equal total values
Handles missing prices by treating as zero value
Handles zero quantities by treating as zero value
Does not mutate original array
Acceptance Criteria Met:
Holdings rendered in descending total value order ✓
Order updates when cache data changes ✓
Stable secondary sort for equal values ✓
Sort applied before render (via useMemo) ✓
closes #673