Skip to content

Commit

Permalink
fix(points): show correct rankings and winner points
Browse files Browse the repository at this point in the history
  • Loading branch information
jonassimoen committed Jan 17, 2024
1 parent 6cf115a commit 1f0d9dd
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions src/controllers/Team.ts
Original file line number Diff line number Diff line change
Expand Up @@ -176,9 +176,9 @@ export const GetPointsTeamHandler = async (req: any, rep: any) => {
weekId: +req.params.weekId,
}
});
const weeklyData: [{ teamId: number, points: number, rank: number }] = await prisma.$queryRaw`SELECT "teamId", CAST(SUM(points) AS int) AS points, CAST(RANK() OVER(ORDER BY SUM(points)) AS int) FROM "Selection" s WHERE "weekId" = ${+req.params.weekId} AND starting = 1 GROUP BY "teamId" ORDER BY rank DESC`;
const globalData: [{ teamId: number, points: number, rank: number }] = await prisma.$queryRaw`SELECT "teamId", CAST(SUM(points) AS int) AS points, CAST(RANK() OVER(ORDER BY SUM(points)) AS int) FROM "Selection" s WHERE starting = 1 GROUP BY "teamId" ORDER BY rank DESC`;
const weeklyData: [{ teamId: number, points: number, rank: number }] = await prisma.$queryRaw`SELECT "teamId", CAST(SUM(points) AS int) AS points, CAST(RANK() OVER(ORDER BY SUM(points) DESC) AS int) FROM "Selection" s WHERE "weekId" = ${+req.params.weekId} AND starting = 1 GROUP BY "teamId" ORDER BY rank ASC`;
const globalData: [{ teamId: number, points: number, rank: number }] = await prisma.$queryRaw`SELECT "teamId", CAST(SUM(points) AS int) AS points, CAST(RANK() OVER(ORDER BY SUM(points) DESC) AS int) FROM "Selection" s WHERE starting = 1 GROUP BY "teamId" ORDER BY rank ASC`;

rep.send({
players,
team: {
Expand Down

0 comments on commit 1f0d9dd

Please sign in to comment.