Skip to content

Commit

Permalink
Order validators by score
Browse files Browse the repository at this point in the history
  • Loading branch information
Albermonte committed May 31, 2024
1 parent 86ad46c commit f0d6ba0
Showing 1 changed file with 3 additions and 0 deletions.
3 changes: 3 additions & 0 deletions server/api/validators/index.get.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
import { desc } from 'drizzle-orm';

export default defineEventHandler(async (event) => {
const data = await useDrizzle()
.select({
Expand All @@ -18,6 +20,7 @@ export default defineEventHandler(async (event) => {
.from(tables.validators)
.leftJoin(tables.scores, eq(tables.validators.id, tables.scores.validatorId))
.groupBy(tables.validators.id)
.orderBy(desc(tables.scores.total))
.all()

setResponseStatus(event, 200)
Expand Down

0 comments on commit f0d6ba0

Please sign in to comment.