Skip to content

Commit

Permalink
feat: win probability and excitement
Browse files Browse the repository at this point in the history
  • Loading branch information
BlueSCar committed Feb 1, 2025
1 parent 2c1e130 commit 067b3ca
Show file tree
Hide file tree
Showing 5 changed files with 13 additions and 0 deletions.
4 changes: 4 additions & 0 deletions src/app/games/service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,7 @@ export const getGames = async (
'venue.name as venue',
'venue.city',
'venue.state',
'game.excitement',
])
.orderBy('game.startDate', 'asc')
.limit(3000);
Expand Down Expand Up @@ -136,6 +137,9 @@ export const getGames = async (
awayPoints: game.awayPoints,
awayPeriodPoints: game.awayPeriodPoints,
awayWinner: game.awayWinner,
excitement: game.excitement
? Math.round(Number(game.excitement) * 10) / 10
: null,
venueId: game.venueId,
venue: game.venue,
city: game.city,
Expand Down
1 change: 1 addition & 0 deletions src/app/games/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,7 @@ export interface GameInfo {
*/
awayPeriodPoints: number[] | null;
awayWinner: boolean | null;
excitement: number | null;
/**
* @isInt
*/
Expand Down
4 changes: 4 additions & 0 deletions src/app/plays/service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -83,6 +83,7 @@ const getPlays = async (
'play.scoreValue',
'playType.name as playType',
'play.playText',
'play.wp',
jsonArrayFrom(
eb
.selectFrom('athlete')
Expand Down Expand Up @@ -181,6 +182,9 @@ const getPlays = async (
: null,
homeScore: play.homeScore,
awayScore: play.awayScore,
homeWinProbability: play.wp
? Math.round(Number(play.wp) * 1000) / 1000
: null,
period: play.period,
clock: play.clock,
secondsRemaining: play.secondsRemaining,
Expand Down
1 change: 1 addition & 0 deletions src/app/plays/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,7 @@ export interface PlayInfo {
* @isInt
*/
awayScore: number;
homeWinProbability: number | null;
scoringPlay: boolean | null;
shootingPlay: boolean | null;
scoreValue: number | null;
Expand Down
3 changes: 3 additions & 0 deletions src/config/types/db.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -97,6 +97,7 @@ export interface ConferenceTeam {
export interface Game {
attendance: number | null;
conferenceGame: Generated<boolean>;
excitement: Numeric | null;
gameType: string | null;
id: Generated<number>;
neutralSite: Generated<boolean>;
Expand All @@ -122,6 +123,7 @@ export interface GameInfo {
awayTeamId: number | null;
awayWinner: boolean | null;
conferenceGame: boolean | null;
excitement: Numeric | null;
gameType: string | null;
homeConference: string | null;
homeConferenceId: number | null;
Expand Down Expand Up @@ -274,6 +276,7 @@ export interface Play {
sourceId: string;
teamId: number | null;
wallclock: Timestamp | null;
wp: Numeric | null;
}

export interface PlayType {
Expand Down

0 comments on commit 067b3ca

Please sign in to comment.