-
Notifications
You must be signed in to change notification settings - Fork 38
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
[Dashboard|SDK] Implemented leaders sorting #2904
Conversation
The latest updates on your projects. Learn more about Vercel for Git ↗︎
2 Skipped Deployments
|
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.
Few extra questions:
- Are these
md
files updates automatic? Could you please shed some light on how/when we run it? - What about a UI counterpart? This PR focuses on BE side, are we going to implement actual logic to fetch values using "sort criteria" selected by user in a different one?
packages/apps/dashboard/server/src/modules/details/details.service.ts
Outdated
Show resolved
Hide resolved
packages/sdk/typescript/human-protocol-sdk/src/graphql/queries/operator.ts
Show resolved
Hide resolved
packages/sdk/typescript/human-protocol-sdk/src/graphql/queries/operator.ts
Outdated
Show resolved
Hide resolved
packages/apps/dashboard/server/src/modules/details/dto/details-pagination.dto.ts
Outdated
Show resolved
Hide resolved
packages/apps/dashboard/server/src/modules/details/dto/details-pagination.dto.ts
Outdated
Show resolved
Hide resolved
packages/apps/dashboard/server/src/modules/details/dto/details-pagination.dto.ts
Outdated
Show resolved
Hide resolved
packages/apps/dashboard/server/src/modules/details/details.service.ts
Outdated
Show resolved
Hide resolved
For typescript SDK:
|
@dnechay @portuu3 comments were resolved, ready for review I want to point out that when users choose to sort leaders by reputation, leaders with a null reputation are currently not displayed. I haven't added logic in the And I updated reputation oracle |
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.
@portuu3 tested locally, seems working as expected
Issue tracking
This issue is being tracked in the following GitHub issue: [Dashboard] Support leaderboard sorting by reputation and fee on BE
#2778
Context behind the change
The changes in this pull request aim to improve how leaderboards are sorted in the application. Previously, sorting was done only on the client-side, leading to performance issues and mismatches with user expectations. Now, the sorting is handled server-side to ensure that the results are accurately sorted according to the selected criteria.
Key changes:
Backend (Details controller and service):
/leaders
controller to accept sorting parameters (orderBy
,orderDirection
,first
, andskip
).getLeader
method in the Details Service to handle sorting by various criteria (e.g., fee, reputation, amountStaked, role).assignReputationsToLeaders
method to ensure default reputation values are assigned when reputation data is missing.SDK updates:
LeaderFilter
in both Python and TypeScript SDKs to accept additional parameters such asroles
,minAmountStaked
, andorderBy
. In order to effectively filter data at the subgraph level and request the data we need.GET_LEADERS_QUERY
GraphQL query to support these new parameters.getLeaders
method inOperatorUtils
to handle the new filtering and sorting logic.How has this been tested?
Unit Tests:
Manual Testing:
/leaders
endpoint to ensure it handles sorting by multiple criteria such as fee, reputation, amount staked, and role.minAmountStaked
androles
.Release Plan
Frontend
Implement sorting on Dashboard UI side.
Suggestion
It would be good to unify the list of roles, since the spelling varies from service to service.
Identified issue: Multi-chain sorting inaccuracy
During development, I noticed a sorting issue when querying leaders across multiple chain IDs. When retrieving data from multiple networks (e.g. getAvailableNetworks return more than one
chainId
), the sorting of the aggregated results becomes incorrect. This happens because sorting is performed separately within each subgraph on the SDK side, not across all queried chains simultaneously and together.Since the subgraph only sorts data within its own chain-specific dataset, fetching results from multiple chain IDs involves sending separate requests. After receiving these sorted lists, we flatten (concatenate) them in the application, causing the global sorting to be inaccurate.
A possible solution is to implement back-end sorting after aggregating results from multiple chain IDs. However, this approach may be inefficient.