Skip to content

feat: return and sort leaderboard by vp_value #1037

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

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 9 additions & 2 deletions src/graphql/operations/leaderboards.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,13 @@ export default async function (parent, args) {

checkLimits(args, 'leaderboards');

const ORDER_FIELDS = ['vote_count', 'proposal_count', 'last_vote', 'user'];
const ORDER_FIELDS = [
'vote_count',
'proposal_count',
'last_vote',
'user',
'vp_value'
];
const DEFAULT_ORDER_FIELD = 'vote_count';

const fields = {
Expand Down Expand Up @@ -37,7 +43,8 @@ export default async function (parent, args) {
SELECT l.*,
l.vote_count as votesCount,
l.proposal_count as proposalsCount,
l.last_vote as lastVote
l.last_vote as lastVote,
l.vp_value as vpValue
FROM leaderboard l
WHERE 1=1 ${whereQuery.query}
ORDER BY ${orderQuery} LIMIT ?, ?
Expand Down
14 changes: 8 additions & 6 deletions src/graphql/schema.gql
Original file line number Diff line number Diff line change
Expand Up @@ -225,12 +225,12 @@ input ProposalWhere {
labels_in: [String]
state: String
space_verified: Boolean
flagged: Boolean,
votes: Int,
votes_gt: Int,
votes_gte: Int,
votes_lt: Int,
votes_lte: Int,
flagged: Boolean
votes: Int
votes_gt: Int
votes_gte: Int
votes_lt: Int
votes_lte: Int
scores_total_value: Float
scores_total_value_in: [Float]
scores_total_value_gt: Float
Expand Down Expand Up @@ -555,6 +555,7 @@ type Vote {
vp: Float
vp_by_strategy: [Float]
vp_state: String
vp_value: Float
}

type Alias {
Expand Down Expand Up @@ -667,6 +668,7 @@ type Leaderboard {
proposalsCount: Int
votesCount: Int
lastVote: Int
vpValue: Float
}

type Option {
Expand Down