Skip to content

Commit

Permalink
fixed getRank method
Browse files Browse the repository at this point in the history
  • Loading branch information
GhomKrosmonaute committed Oct 27, 2024
1 parent 33d7a15 commit ba2a27e
Showing 1 changed file with 7 additions and 4 deletions.
11 changes: 7 additions & 4 deletions src/namespaces/point.ts
Original file line number Diff line number Diff line change
Expand Up @@ -49,17 +49,20 @@ export const pointLadder = new app.Ladder<PointLadderLine>({
},
})

export function getPointRank(user: app.User): Promise<{ rank: string }> {
return point.query
export async function getPointRank(user: app.User): Promise<{ rank: string }> {
const result = await point.query
.select([
"user.id",
app.database.raw(
'rank() over (order by sum("point"."amount") desc) as "rank"',
),
])
.leftJoin("user", "point.to_id", "user._id")
.where("user.id", user.id)
.groupBy("point.to_id")
.groupBy("user.id")
.having("user.id", "=", user.id)
.first()

return { rank: result.rank }
}

export function buildHelpingFooterEmbed(
Expand Down

0 comments on commit ba2a27e

Please sign in to comment.