Skip to content

Conversation

@alisonhawk
Copy link
Contributor

@alisonhawk alisonhawk commented Feb 13, 2025

Description

As mentioned in the issue #258
The issue is caused because donors are sorted by their past contribution not taking into account their current active stream.
In the display of each donor the amount displayed is past contribution + time*flowrate

Fixed:

  • in DonorsList add to each donor his current total donation (as calculated in DonorsListItem
  • sort the donors list by the total donation value

image

About #258

How Has This Been Tested?

live using the dev server

Please describe the tests that you ran to verify your changes.

Checklist:

  • PR title matches follow: (Feature|Bug|Chore) Task Name
  • My code follows the style guidelines of this project
  • I have followed all the instructions described in the initial task (check Definitions of Done)
  • I have performed a self-review of my own code
  • My changes generate no new warnings
  • I have added tests that prove my fix is effective or that my feature works
  • New and existing unit tests pass locally with my changes
  • I have added reference to a related issue in the repository
  • I have added a detailed description of the changes proposed in the pull request. I am as descriptive as possible, assisting reviewers as much as possible.
  • I have added screenshots related to my pull request (for frontend tasks)
  • I have pasted a gif showing the feature.
  • @mentions of the person or team responsible for reviewing proposed changes

Description by Korbit AI

What change is being made?

Refactor the donor sorting logic on the DonorsList component by utilizing new hooks useDonorWithTotal and useDonorsWithTotal to accurately calculate and sort donors based on total donations.

Why are these changes being made?

The previous implementation incorrectly sorted donors due to the inappropriate usage of the Decimal library. This refactoring introduces a more reliable hook-based approach to ensure accurate sorting, aligning donor contributions with their total donations, and ensuring consistency across donor listings.

Is this description stale? Ask me to generate a new description by commenting /korbit-generate-pr-description

Copy link

@sourcery-ai sourcery-ai bot left a comment

Choose a reason for hiding this comment

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

Hey @alisonhawk - I've reviewed your changes - here's some feedback:

Overall Comments:

  • It looks like you're calculating totalDonations in a few different places; can you consolidate this logic into a single hook or utility function?
Here's what I looked at during the review
  • 🟡 General issues: 1 issue found
  • 🟢 Security: all looks good
  • 🟢 Testing: all looks good
  • 🟢 Complexity: all looks good
  • 🟢 Documentation: all looks good

Sourcery is free for open source - if you like our reviews please consider sharing them ✨
Help me be more useful! Please click 👍 or 👎 on each comment and I'll use the feedback to improve your reviews.

Copy link

@korbit-ai korbit-ai bot left a comment

Choose a reason for hiding this comment

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

Review by Korbit AI

Korbit automatically attempts to detect when you fix issues in new commits.
Category Issue Fix Detected
Functionality Incorrect Sort Comparison Logic ▹ view
Performance Inefficient BigInt Conversion ▹ view
Functionality Potentially incorrect flow rate calculation due to undefined parameter ▹ view
Files scanned
File Path Reviewed
packages/app/src/hooks/donors/useDonorWithTotal.ts
packages/app/src/hooks/donors/useDonorsWithTotal.ts
packages/app/src/components/DonorsList/DonorsList.tsx
packages/app/src/pages/ViewDonorsPage.tsx

Explore our documentation to understand the languages and file types we support and the files we ignore.

Need a new review? Comment /korbit-review on this PR and I'll review your latest changes.

Korbit Guide: Usage and Customization

Interacting with Korbit

  • You can manually ask Korbit to review your PR using the /korbit-review command in a comment at the root of your PR.
  • You can ask Korbit to generate a new PR description using the /korbit-generate-pr-description command in any comment on your PR.
  • Too many Korbit comments? I can resolve all my comment threads if you use the /korbit-resolve command in any comment on your PR.
  • Chat with Korbit on issues we post by tagging @korbit-ai in your reply.
  • Help train Korbit to improve your reviews by giving a 👍 or 👎 on the comments Korbit posts.

Customizing Korbit

  • Check out our docs on how you can make Korbit work best for you and your team.
  • Customize Korbit for your organization through the Korbit Console.

Feedback and Support

const donorsWithTotal = donors.map(useDonorWithTotal);

return useMemo(
() => donorsWithTotal.sort((a, b) => (b.totalDonations > a.totalDonations ? 1 : -1)),

This comment was marked as resolved.

Copy link
Contributor

@sirpy sirpy left a comment

Choose a reason for hiding this comment

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

Better use lodash sort for your sorting needs

@alisonhawk
Copy link
Contributor Author

@sirpy Pushed requested changes

@alisonhawk
Copy link
Contributor Author

@sirpy can you merge it?

@sirpy sirpy merged commit ab1bfd0 into GoodDollar:master Feb 18, 2025
2 of 3 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants