Skip to content

Commit 9daef0e

Browse files
committed
feat(plays): tracking players on floor
1 parent 9a0dae8 commit 9daef0e

File tree

2 files changed

+22
-0
lines changed

2 files changed

+22
-0
lines changed

src/app/plays/service.ts

+14
Original file line numberDiff line numberDiff line change
@@ -193,6 +193,19 @@ const getPlays = async (
193193
)
194194
.select(['athlete.id', 'athlete.name']),
195195
).as('participants'),
196+
jsonArrayFrom(
197+
eb
198+
.selectFrom('substitution')
199+
.innerJoin('athlete', 'substitution.athleteId', 'athlete.id')
200+
.innerJoin('team', 'substitution.teamId', 'team.id')
201+
.whereRef('substitution.gameId', '=', 'gameInfo.id')
202+
.where(
203+
'substitution.timeRange',
204+
'@>',
205+
sql<string>`(CASE WHEN play.period = 1 THEN 1200 - play.seconds_remaining WHEN play.period = 2 THEN 2400 - play.seconds_remaining ELSE 2400 + (play.period - 2) * 300 - play.seconds_remaining END)::numeric`,
206+
)
207+
.select(['athlete.id', 'athlete.name', 'team.school as team']),
208+
).as('onFloor'),
196209
]);
197210

198211
if (season) {
@@ -325,6 +338,7 @@ const getPlays = async (
325338
: { x: null, y: null },
326339
}
327340
: null,
341+
onFloor: play.onFloor,
328342
};
329343
})
330344
.filter((play) => play.gameId !== -1);

src/app/plays/types.ts

+8
Original file line numberDiff line numberDiff line change
@@ -67,6 +67,14 @@ export interface PlayInfo {
6767
id: number;
6868
name: string;
6969
}[];
70+
onFloor: {
71+
/**
72+
* @isInt
73+
*/
74+
id: number;
75+
name: string;
76+
team: string;
77+
}[];
7078
shotInfo: ShotInfo | null;
7179
}
7280

0 commit comments

Comments
 (0)