@@ -3,10 +3,12 @@ import { type NextRequest, NextResponse } from "next/server";
33import { adminProtected } from "~/auth/routes-wrapper" ;
44import db from "~/db" ;
55import {
6+ ideaSubmission ,
67 panelCriterias ,
78 panelTeamRoundScores ,
89 teamRoundScores ,
910 teams ,
11+ tracks ,
1012} from "~/db/schema" ;
1113
1214export const GET = adminProtected ( async ( req : NextRequest ) => {
@@ -37,9 +39,13 @@ export const GET = adminProtected(async (req: NextRequest) => {
3739 rawTotalScore : panelTeamRoundScores . rawTotalScore ,
3840 normalizedTotalScore : panelTeamRoundScores . normalizedTotalScore ,
3941 panelistCount : panelTeamRoundScores . panelistCount ,
42+ trackId : ideaSubmission . trackId ,
43+ trackName : tracks . name ,
4044 } )
4145 . from ( panelTeamRoundScores )
4246 . innerJoin ( teams , eq ( teams . id , panelTeamRoundScores . teamId ) )
47+ . leftJoin ( ideaSubmission , eq ( ideaSubmission . teamId , panelTeamRoundScores . teamId ) )
48+ . leftJoin ( tracks , eq ( tracks . id , ideaSubmission . trackId ) )
4349 . where ( eq ( panelTeamRoundScores . roundId , panelRoundId ) ) ;
4450
4551 // Judge Z-score totals (sum of normalized_total_score across ALL judge rounds per team)
@@ -90,6 +96,8 @@ export const GET = adminProtected(async (req: NextRequest) => {
9096 return {
9197 teamId : row . teamId ,
9298 teamName : row . teamName ,
99+ trackId : row . trackId ?? null ,
100+ trackName : row . trackName ?? null ,
93101 rawTotalScore : row . rawTotalScore ?? 0 ,
94102 normalizedTotalScore : row . normalizedTotalScore ?? 0 ,
95103 maxPossibleScore,
0 commit comments