-
-
Notifications
You must be signed in to change notification settings - Fork 660
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
feat: sort transactions better #470
feat: sort transactions better #470
Conversation
WalkthroughThe changes include the addition of new test cases for the Changes
Thank you for using CodeRabbit. We offer it for free to the OSS community and would appreciate your support in helping us grow. If you find it useful, would you consider giving us a shout-out on your favorite social media? 🪧 TipsChatThere are 3 ways to chat with CodeRabbit:
Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments. CodeRabbit Commands (Invoked using PR comments)
Other keywords and placeholders
CodeRabbit Configuration File (
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Actionable comments posted: 2
📜 Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
⛔ Files ignored due to path filters (1)
upcoming-release-notes/470.md
is excluded by!**/*.md
📒 Files selected for processing (2)
- src/app-gocardless/tests/utils.spec.js (1 hunks)
- src/app-gocardless/utils.js (1 hunks)
🔇 Additional comments (4)
src/app-gocardless/utils.js (2)
19-27
:compareFunctions
array is correctly structured for sequential date comparisonsThe array
compareFunctions
is well-defined, allowing the sorting mechanism to compare multiple date fields in sequence. This approach ensures that if one date field is equal or unavailable, the next available date field is used for comparison, enhancing the robustness and accuracy of the sorting process.
30-38
: Confirm the argument order insortFunction(b, a)
to ensure correct sorting orderIn the
sortByBookingDateOrValueDate
function, the comparator callssortFunction(b, a)
instead ofsortFunction(a, b)
. Swapping the arguments reverses the comparison result, which will sort the transactions in descending order (newest first). Please verify that this ordering aligns with the intended sorting behavior.If the goal is to sort transactions from newest to oldest, then the current implementation is correct. Otherwise, consider changing the call to
sortFunction(a, b)
to sort in ascending order.src/app-gocardless/tests/utils.spec.js (2)
37-66
: Test case correctly verifies sorting byvalueDate
whenbookingDate
is missingThe test case
'should sort by valueDate if bookingDate is missing'
appropriately checks that transactions are sorted from newest to oldest based on thevalueDate
field when thebookingDate
is unavailable.
115-160
: Clarify the purpose of discrepancies betweenbookingDate
andvalueDateTime
In the test case
'should sort on booking date if value date is widely off'
, some transactions havevalueDateTime
values that are significantly different from theirbookingDate
. For instance:
- At lines 128-131, a transaction has:
bookingDate
:'2023-01-30'
valueDateTime
:'2023-01-01T12:00:00Z'
This could either be intentional to simulate scenarios where
valueDateTime
is not aligned withbookingDate
, or it might be an oversight.Please verify if this discrepancy is intentional. If it is meant to test the sorting behavior when
valueDateTime
deviates significantly frombookingDate
, consider adding comments to explain the scenario. Ensuring clarity will help maintainers and future contributors understand the purpose of the test.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thank you for this, I like the idea. I think there is a consideration to be made regarding the performance hit, but I did some testing and it doesn't seem to cause a pronounced slowdown even with a full 90 days of data.
I noticed that the transaction that were synced were really out of order of how they happend. This should fix this by also sorting on time