Skip to content
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(portfolio): new utility to get top projects for the ProjectsCard #6159

Open
wants to merge 4 commits into
base: main
Choose a base branch
from

Conversation

yhabib
Copy link
Contributor

@yhabib yhabib commented Jan 14, 2025

Motivation

The Portfolio page displays a list of projects that behaves differently based on specific rules.

The getTopProjects function encapsulates the following logic:

  • It should return up to four projects.
  • When the user is logged out, the function returns the top four projects, listing ICP first, followed by three sorted by name. This is similar to how we do it in the Staking page when the user is logged out.
  • When the user is logged in, it returns the projects with the highest stakeInUsd. If ICP is present, it should be the first item in the list.

Changes

  • Added a new descending comparator, compareProjectsByUsdBalance
  • Exported compareIcpFirst and compareByProjectTitle from staking.utils to build the sorting comparator.
  • Introduced a new utility, getTopProjects

Tests

  • Created unit tests for getTopProjects

Todos

  • Add an entry to the changelog (if necessary). Not necessary.
    Not necessary.

@yhabib yhabib changed the title feat(portfolio): add getTopTokens utility for ProjectsCard feat(portfolio): new utility to get top projects for the ProjectsCard Jan 14, 2025
@yhabib yhabib marked this pull request as ready for review January 14, 2025 14:41
@yhabib yhabib requested a review from a team as a code owner January 14, 2025 14:41
@yhabib yhabib force-pushed the nns1-3521/top-projects-util branch from 09c4b93 to 1c17321 Compare January 15, 2025 05:23
Copy link
Contributor

@mstrasinskis mstrasinskis left a comment

Choose a reason for hiding this comment

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

Thanks!

*/
export const getTopProjects = ({
projects,
maxResults = MAX_NUMBER_OF_ITEMS,
Copy link
Contributor

Choose a reason for hiding this comment

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

Where is this parameter going to be used?

@yhabib yhabib force-pushed the nns1-3521/top-projects-util branch from 076740a to 54d6566 Compare January 15, 2025 10:25
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