Cutover to new API for local development and fix standings season issue

This commit is contained in:
Peter 2025-10-21 08:43:58 -05:00
parent 16e6099fc3
commit 642dc6e673
15 changed files with 59 additions and 60 deletions

View File

@ -26,7 +26,7 @@
<tr v-for="(team, index) in getSortedStandings(division.teamStandings)" :key="index"> <tr v-for="(team, index) in getSortedStandings(division.teamStandings)" :key="index">
<td> <td>
<RouterLink <RouterLink
:to="{ name: 'team', params: { seasonNumber: seasonNumber(), teamAbbreviation: team.teamAbbreviation } }"> :to="{ name: 'team', params: { seasonNumber: team.season, teamAbbreviation: team.teamAbbreviation } }">
{{ team.teamName }} {{ team.teamName }}
</RouterLink> </RouterLink>
</td> </td>
@ -54,7 +54,6 @@
<script lang="ts"> <script lang="ts">
import type { TeamStanding } from '@/services/standingsService' import type { TeamStanding } from '@/services/standingsService'
import { CURRENT_SEASON } from '@/services/utilities'
interface DivisionStub { interface DivisionStub {
name: string name: string
@ -94,9 +93,6 @@ export default {
record(teamStanding: TeamStanding): string { record(teamStanding: TeamStanding): string {
return `${teamStanding.wins}-${teamStanding.losses}` return `${teamStanding.wins}-${teamStanding.losses}`
}, },
seasonNumber(): number {
return CURRENT_SEASON
},
getSortedStandings(teamStandings: TeamStanding[]): TeamStanding[] { getSortedStandings(teamStandings: TeamStanding[]): TeamStanding[] {
if (!teamStandings) return [] if (!teamStandings) return []
return teamStandings.slice() return teamStandings.slice()

View File

@ -68,7 +68,8 @@ export default {
return `${teamStanding.wins}-${teamStanding.losses}` return `${teamStanding.wins}-${teamStanding.losses}`
}, },
seasonNumber(): number { seasonNumber(): number {
return CURRENT_SEASON if (!this.teams) return CURRENT_SEASON
return this.teams[0].season
} }
} }
} }

View File

@ -1,6 +1,6 @@
import type { Manager, Team } from './apiResponseTypes' import type { Manager, Team } from './apiResponseTypes'
import type { Player } from './playersService' import type { Player } from './playersService'
import { SITE_URL } from './utilities' import { API_URL } from './utilities'
export interface Award { export interface Award {
id: number, id: number,
@ -15,7 +15,7 @@ export interface Award {
} }
export async function fetchAwardsByPlayerName(playerName: string): Promise<Award[]> { export async function fetchAwardsByPlayerName(playerName: string): Promise<Award[]> {
const response = await fetch(`${SITE_URL}/api/v3/awards?player_name=${playerName}&timing=off-season`) const response = await fetch(`${API_URL}/awards?player_name=${playerName}&timing=off-season`)
const awardsResponse: { const awardsResponse: {
count: number count: number
@ -26,7 +26,7 @@ export async function fetchAwardsByPlayerName(playerName: string): Promise<Award
} }
export async function fetchAwardsByManagerId(managerId: number): Promise<Award[]> { export async function fetchAwardsByManagerId(managerId: number): Promise<Award[]> {
const response = await fetch(`${SITE_URL}/api/v3/awards?manager_id=${managerId}`) const response = await fetch(`${API_URL}/awards?manager_id=${managerId}`)
const awardsResponse: { const awardsResponse: {
count: number count: number

View File

@ -1,6 +1,6 @@
import type { Game, Team } from './apiResponseTypes' import type { Game, Team } from './apiResponseTypes'
import type { Player } from './playersService' import type { Player } from './playersService'
import { MODERN_STAT_ERA_START, SITE_URL, avg, obp, ops, slg, woba } from './utilities' import { MODERN_STAT_ERA_START, API_URL, avg, obp, ops, slg, woba } from './utilities'
// TODO make a stats object that has properties for current regular season, current post season, // TODO make a stats object that has properties for current regular season, current post season,
// last 4 games, historical seasons, career totals // last 4 games, historical seasons, career totals
@ -71,7 +71,7 @@ export async function fetchBattingStatsBySeason(seasonNumber: number, isRegularS
return [] return []
} }
const response = await fetch(`${SITE_URL}/api/v3/plays/batting?season=${seasonNumber}&group_by=player&limit=1000&s_type=${isRegularSeason ? 'regular' : 'post'}`) const response = await fetch(`${API_URL}/plays/batting?season=${seasonNumber}&group_by=player&limit=1000&s_type=${isRegularSeason ? 'regular' : 'post'}`)
const battingStatsResponse: { const battingStatsResponse: {
count: number count: number
@ -89,7 +89,7 @@ export async function fetchBattingStatsBySeasonAndPlayerId(seasonNumber: number,
return await fetchLegacyBattingStatsBySeasonAndPlayerId(seasonNumber, playerId, isRegularSeason) return await fetchLegacyBattingStatsBySeasonAndPlayerId(seasonNumber, playerId, isRegularSeason)
} }
const response = await fetch(`${SITE_URL}/api/v3/plays/batting?season=${seasonNumber}&player_id=${playerId}&s_type=${isRegularSeason ? 'regular' : 'post'}`) const response = await fetch(`${API_URL}/plays/batting?season=${seasonNumber}&player_id=${playerId}&s_type=${isRegularSeason ? 'regular' : 'post'}`)
const battingStatsResponse: { const battingStatsResponse: {
count: number count: number
@ -111,7 +111,7 @@ export async function fetchBattingStatsBySeasonAndTeamId(seasonNumber: number, t
return [] return []
} }
const response = await fetch(`${SITE_URL}/api/v3/plays/batting?season=${seasonNumber}&team_id=${teamId}&group_by=playerteam&s_type=${isRegularSeason ? 'regular' : 'post'}`) const response = await fetch(`${API_URL}/plays/batting?season=${seasonNumber}&team_id=${teamId}&group_by=playerteam&s_type=${isRegularSeason ? 'regular' : 'post'}`)
const battingStatsResponse: { const battingStatsResponse: {
count: number count: number
@ -130,7 +130,7 @@ export async function fetchTeamBattingStatsBySeason(seasonNumber: number): Promi
return [] return []
} }
const response = await fetch(`${SITE_URL}/api/v3/plays/batting?season=${seasonNumber}&group_by=team&s_type=regular`) const response = await fetch(`${API_URL}/plays/batting?season=${seasonNumber}&group_by=team&s_type=regular`)
const battingStatsResponse: { const battingStatsResponse: {
count: number count: number
@ -143,7 +143,7 @@ export async function fetchTeamBattingStatsBySeason(seasonNumber: number): Promi
} }
async function fetchLegacyBattingStatsBySeasonAndPlayerId(seasonNumber: number, playerId: number, isRegularSeason: boolean): Promise<BattingStat | undefined> { async function fetchLegacyBattingStatsBySeasonAndPlayerId(seasonNumber: number, playerId: number, isRegularSeason: boolean): Promise<BattingStat | undefined> {
const response = await fetch(`${SITE_URL}/api/v3/battingstats/totals?season=${seasonNumber}&player_id=${playerId}&s_type=${isRegularSeason ? 'regular' : 'post'}`) const response = await fetch(`${API_URL}/battingstats/totals?season=${seasonNumber}&player_id=${playerId}&s_type=${isRegularSeason ? 'regular' : 'post'}`)
const legacyBattingStatsResponse: { const legacyBattingStatsResponse: {
count: number count: number
@ -160,7 +160,7 @@ async function fetchLegacyBattingStatsBySeasonAndPlayerId(seasonNumber: number,
} }
export async function fetchBattingStatsForLastFourGamesBySeasonAndPlayerId(seasonNumber: number, playerId: number): Promise<BattingStat[]> { export async function fetchBattingStatsForLastFourGamesBySeasonAndPlayerId(seasonNumber: number, playerId: number): Promise<BattingStat[]> {
const response = await fetch(`${SITE_URL}/api/v3/plays/batting?season=${seasonNumber}&player_id=${playerId}&group_by=playergame&limit=4&s_type=regular&sort=newest`) const response = await fetch(`${API_URL}/plays/batting?season=${seasonNumber}&player_id=${playerId}&group_by=playergame&limit=4&s_type=regular&sort=newest`)
const battingStatsResponse: { const battingStatsResponse: {
count: number count: number
@ -180,7 +180,7 @@ export async function fetchBattingStatsBySeries(seasonNumber: number, weekNumber
return [] return []
} }
const response = await fetch(`${SITE_URL}/api/v3/plays/batting?season=${seasonNumber}&week=${weekNumber}&team_id=${homeTeamId}&team_id=${awayTeamId}&group_by=playergame`) const response = await fetch(`${API_URL}/plays/batting?season=${seasonNumber}&week=${weekNumber}&team_id=${homeTeamId}&team_id=${awayTeamId}&group_by=playergame`)
const battingStatsResponse: { const battingStatsResponse: {
count: number count: number

View File

@ -1,4 +1,4 @@
import { SITE_URL } from './utilities' import { API_URL } from './utilities'
export interface LeagueInfo { export interface LeagueInfo {
id: number, id: number,
@ -17,7 +17,7 @@ export interface LeagueInfo {
} }
export async function fetchCurrentLeagueInfo(): Promise<LeagueInfo> { export async function fetchCurrentLeagueInfo(): Promise<LeagueInfo> {
const response = await fetch(`${SITE_URL}/api/v3/current`) const response = await fetch(`${API_URL}/current`)
const leagueInfoResponse: LeagueInfo = await response.json() const leagueInfoResponse: LeagueInfo = await response.json()

View File

@ -1,6 +1,6 @@
import type { Game } from './apiResponseTypes' import type { Game } from './apiResponseTypes'
import type { Player } from './playersService' import type { Player } from './playersService'
import { SITE_URL } from './utilities' import { API_URL } from './utilities'
export interface Decision { export interface Decision {
id: number, id: number,
@ -22,7 +22,7 @@ export interface Decision {
} }
export async function fetchLast2DecisionsByPlayerId(seasonNumber: number, playerId: number): Promise<Decision[]> { export async function fetchLast2DecisionsByPlayerId(seasonNumber: number, playerId: number): Promise<Decision[]> {
const response = await fetch(`${SITE_URL}/api/v3/decisions?season=${seasonNumber}&player_id=${playerId}&limit=2`) const response = await fetch(`${API_URL}/decisions?season=${seasonNumber}&player_id=${playerId}&limit=2`)
const decisionsResponse: { const decisionsResponse: {
count: number count: number

View File

@ -1,6 +1,6 @@
import type { Game, Team } from './apiResponseTypes' import type { Game, Team } from './apiResponseTypes'
import type { Player } from './playersService' import type { Player } from './playersService'
import { MODERN_STAT_ERA_START, SITE_URL, isNotUndefined } from './utilities' import { MODERN_STAT_ERA_START, API_URL, isNotUndefined } from './utilities'
// TODO make a stats object that has properties for current regular season, current post season, // TODO make a stats object that has properties for current regular season, current post season,
// last 4 games, historical seasons, career totals // last 4 games, historical seasons, career totals
@ -58,7 +58,7 @@ export async function fetchFieldingStatsBySeasonAndPlayerId(seasonNumber: number
return await fetchLegacyFieldingStatsBySeasonAndPlayerId(seasonNumber, playerId, isRegularSeason) return await fetchLegacyFieldingStatsBySeasonAndPlayerId(seasonNumber, playerId, isRegularSeason)
} }
const response = await fetch(`${SITE_URL}/api/v3/plays/fielding?season=${seasonNumber}&player_id=${playerId}&group_by=playerposition&s_type=${isRegularSeason ? 'regular' : 'post'}`) const response = await fetch(`${API_URL}/plays/fielding?season=${seasonNumber}&player_id=${playerId}&group_by=playerposition&s_type=${isRegularSeason ? 'regular' : 'post'}`)
const fieldingStatsResponse: { const fieldingStatsResponse: {
count: number count: number
@ -77,7 +77,7 @@ export async function fetchFieldingStatsBySeasonAndTeamId(seasonNumber: number,
} }
// TODO might want to make this playerpositionteam grouping (currently does not exist) // TODO might want to make this playerpositionteam grouping (currently does not exist)
const response = await fetch(`${SITE_URL}/api/v3/plays/fielding?season=${seasonNumber}&team_id=${teamId}&group_by=playerposition&s_type=${isRegularSeason ? 'regular' : 'post'}`) const response = await fetch(`${API_URL}/plays/fielding?season=${seasonNumber}&team_id=${teamId}&group_by=playerposition&s_type=${isRegularSeason ? 'regular' : 'post'}`)
const fieldingStatsResponse: { const fieldingStatsResponse: {
count: number count: number
@ -96,7 +96,7 @@ export async function fetchTeamFieldingStatsBySeason(seasonNumber: number): Prom
} }
// TODO might want to make this playerpositionteam grouping (currently does not exist) // TODO might want to make this playerpositionteam grouping (currently does not exist)
const response = await fetch(`${SITE_URL}/api/v3/plays/fielding?season=${seasonNumber}&group_by=team&s_type=regular`) const response = await fetch(`${API_URL}/plays/fielding?season=${seasonNumber}&group_by=team&s_type=regular`)
const fieldingStatsResponse: { const fieldingStatsResponse: {
count: number count: number
@ -114,7 +114,7 @@ export async function fetchFieldingStatsBySeason(seasonNumber: number, isRegular
return [] return []
} }
const response = await fetch(`${SITE_URL}/api/v3/plays/fielding?season=${seasonNumber}&limit=10000&group_by=playerposition&s_type=${isRegularSeason ? 'regular' : 'post'}`) const response = await fetch(`${API_URL}/plays/fielding?season=${seasonNumber}&limit=10000&group_by=playerposition&s_type=${isRegularSeason ? 'regular' : 'post'}`)
const fieldingStatsResponse: { const fieldingStatsResponse: {
count: number count: number
@ -127,7 +127,7 @@ export async function fetchFieldingStatsBySeason(seasonNumber: number, isRegular
} }
async function fetchLegacyFieldingStatsBySeasonAndPlayerId(seasonNumber: number, playerId: number, isRegularSeason: boolean): Promise<FieldingStat[]> { async function fetchLegacyFieldingStatsBySeasonAndPlayerId(seasonNumber: number, playerId: number, isRegularSeason: boolean): Promise<FieldingStat[]> {
const response = await fetch(`${SITE_URL}/api/v3/fieldingstats/totals?season=${seasonNumber}&player_id=${playerId}&s_type=${isRegularSeason ? 'regular' : 'post'}`) const response = await fetch(`${API_URL}/fieldingstats/totals?season=${seasonNumber}&player_id=${playerId}&s_type=${isRegularSeason ? 'regular' : 'post'}`)
const legacyFieldingStatsResponse: { const legacyFieldingStatsResponse: {
count: number count: number
@ -142,7 +142,7 @@ async function fetchLegacyFieldingStatsBySeasonAndPlayerId(seasonNumber: number,
} }
export async function fetchFieldingStatsForLastFourGamesBySeasonAndPlayerId(seasonNumber: number, playerId: number): Promise<FieldingStat[]> { export async function fetchFieldingStatsForLastFourGamesBySeasonAndPlayerId(seasonNumber: number, playerId: number): Promise<FieldingStat[]> {
const response = await fetch(`${SITE_URL}/api/v3/plays/fielding?season=${seasonNumber}&player_id=${playerId}&group_by=playerpositiongame&limit=4&s_type=regular&sort=newest`) const response = await fetch(`${API_URL}/plays/fielding?season=${seasonNumber}&player_id=${playerId}&group_by=playerpositiongame&limit=4&s_type=regular&sort=newest`)
const fieldingStatsResponse: { const fieldingStatsResponse: {
count: number count: number
@ -162,7 +162,7 @@ export async function fetchFieldingStatsBySeries(seasonNumber: number, weekNumbe
return [] return []
} }
const response = await fetch(`${SITE_URL}/api/v3/plays/fielding?season=${seasonNumber}&week=${weekNumber}&team_id=${homeTeamId}&team_id=${awayTeamId}&group_by=playerpositiongame`) const response = await fetch(`${API_URL}/plays/fielding?season=${seasonNumber}&week=${weekNumber}&team_id=${homeTeamId}&team_id=${awayTeamId}&group_by=playerpositiongame`)
const fieldingStatsResponse: { const fieldingStatsResponse: {
count: number count: number

View File

@ -1,5 +1,5 @@
import type { Game } from './apiResponseTypes' import type { Game } from './apiResponseTypes'
import { MODERN_STAT_ERA_START, SITE_URL } from './utilities' import { MODERN_STAT_ERA_START, API_URL } from './utilities'
export async function fetchGamesBySeasonAndTeamId(seasonNumber: number, teamId: number): Promise<Game[]> { export async function fetchGamesBySeasonAndTeamId(seasonNumber: number, teamId: number): Promise<Game[]> {
if (seasonNumber < MODERN_STAT_ERA_START) { if (seasonNumber < MODERN_STAT_ERA_START) {
@ -7,7 +7,7 @@ export async function fetchGamesBySeasonAndTeamId(seasonNumber: number, teamId:
return [] return []
} }
const response = await fetch(`${SITE_URL}/api/v3/games?season=${seasonNumber}&team1_id=${teamId}&team2_id=${teamId}&season_type=regular`) const response = await fetch(`${API_URL}/games?season=${seasonNumber}&team1_id=${teamId}&team2_id=${teamId}&season_type=regular`)
const gamesResponse: { const gamesResponse: {
count: number count: number
@ -23,7 +23,7 @@ export async function fetchGamesBySeasonAndWeek(seasonNumber: number, weekNumber
return [] return []
} }
const response = await fetch(`${SITE_URL}/api/v3/games?season=${seasonNumber}&week=${weekNumber}`) const response = await fetch(`${API_URL}/games?season=${seasonNumber}&week=${weekNumber}`)
const gamesResponse: { const gamesResponse: {
count: number count: number
@ -39,7 +39,7 @@ export async function fetchSingleGame(seasonNumber: number, weekNumber: number,
return undefined return undefined
} }
const response = await fetch(`${SITE_URL}/api/v3/games?season=${seasonNumber}&week=${weekNumber}&game_num=${gameNumber}&team1_id=${homeTeamId}&team2_id=${awayTeamId}`) const response = await fetch(`${API_URL}/games?season=${seasonNumber}&week=${weekNumber}&game_num=${gameNumber}&team1_id=${homeTeamId}&team2_id=${awayTeamId}`)
const gamesResponse: { const gamesResponse: {
count: number count: number

View File

@ -1,5 +1,5 @@
import type { Manager } from './apiResponseTypes' import type { Manager } from './apiResponseTypes'
import { SITE_URL } from './utilities' import { API_URL } from './utilities'
export async function fetchActiveManagers(): Promise<Manager[]> { export async function fetchActiveManagers(): Promise<Manager[]> {
return await fetchManagers(true) return await fetchManagers(true)
@ -10,7 +10,7 @@ export async function fetchRetiredManagers(): Promise<Manager[]> {
} }
async function fetchManagers(active: boolean): Promise<Manager[]> { async function fetchManagers(active: boolean): Promise<Manager[]> {
const response = await fetch(`${SITE_URL}/api/v3/managers?active=${active}&short_output=true`) const response = await fetch(`${API_URL}/managers?active=${active}&short_output=true`)
const managersResponse: { const managersResponse: {
count: number count: number

View File

@ -1,6 +1,6 @@
import type { Game, Team } from './apiResponseTypes' import type { Game, Team } from './apiResponseTypes'
import type { Player } from './playersService' import type { Player } from './playersService'
import { MODERN_STAT_ERA_START, SITE_URL, avg, slg, woba } from './utilities' import { MODERN_STAT_ERA_START, API_URL, avg, slg, woba } from './utilities'
// TODO make a stats object that has properties for current regular season, current post season, // TODO make a stats object that has properties for current regular season, current post season,
// last 4 games, historical seasons, career totals // last 4 games, historical seasons, career totals
@ -138,7 +138,7 @@ export async function fetchPitchingStatsBySeasonAndPlayerId(seasonNumber: number
return await fetchLegacyPitchingStatsBySeasonAndPlayerId(seasonNumber, playerId, isRegularSeason) return await fetchLegacyPitchingStatsBySeasonAndPlayerId(seasonNumber, playerId, isRegularSeason)
} }
const response = await fetch(`${SITE_URL}/api/v3/plays/pitching?season=${seasonNumber}&player_id=${playerId}&s_type=${isRegularSeason ? 'regular' : 'post'}`) const response = await fetch(`${API_URL}/plays/pitching?season=${seasonNumber}&player_id=${playerId}&s_type=${isRegularSeason ? 'regular' : 'post'}`)
const pitchingStatsResponse: { const pitchingStatsResponse: {
count: number count: number
@ -160,7 +160,7 @@ export async function fetchPitchingStatsBySeasonAndTeamId(seasonNumber: number,
return [] return []
} }
const response = await fetch(`${SITE_URL}/api/v3/plays/pitching?season=${seasonNumber}&team_id=${teamId}&group_by=playerteam&s_type=${isRegularSeason ? 'regular' : 'post'}`) const response = await fetch(`${API_URL}/plays/pitching?season=${seasonNumber}&team_id=${teamId}&group_by=playerteam&s_type=${isRegularSeason ? 'regular' : 'post'}`)
const pitchingStatsResponse: { const pitchingStatsResponse: {
count: number count: number
@ -178,7 +178,7 @@ export async function fetchTeamPitchingStatsBySeason(seasonNumber: number): Prom
return [] return []
} }
const response = await fetch(`${SITE_URL}/api/v3/plays/pitching?season=${seasonNumber}&group_by=team&s_type=regular`) const response = await fetch(`${API_URL}/plays/pitching?season=${seasonNumber}&group_by=team&s_type=regular`)
const pitchingStatsResponse: { const pitchingStatsResponse: {
count: number count: number
@ -197,7 +197,7 @@ export async function fetchPitchingStatsBySeason(seasonNumber: number, isRegular
return [] return []
} }
const response = await fetch(`${SITE_URL}/api/v3/plays/pitching?season=${seasonNumber}&group_by=player&limit=1000&s_type=${isRegularSeason ? 'regular' : 'post'}`) const response = await fetch(`${API_URL}/plays/pitching?season=${seasonNumber}&group_by=player&limit=1000&s_type=${isRegularSeason ? 'regular' : 'post'}`)
const pitchingStatsResponse: { const pitchingStatsResponse: {
count: number count: number
@ -210,7 +210,7 @@ export async function fetchPitchingStatsBySeason(seasonNumber: number, isRegular
} }
async function fetchLegacyPitchingStatsBySeasonAndPlayerId(seasonNumber: number, playerId: number, isRegularSeason: boolean): Promise<PitchingStat | undefined> { async function fetchLegacyPitchingStatsBySeasonAndPlayerId(seasonNumber: number, playerId: number, isRegularSeason: boolean): Promise<PitchingStat | undefined> {
const response = await fetch(`${SITE_URL}/api/v3/pitchingstats/totals?season=${seasonNumber}&player_id=${playerId}&s_type=${isRegularSeason ? 'regular' : 'post'}`) const response = await fetch(`${API_URL}/pitchingstats/totals?season=${seasonNumber}&player_id=${playerId}&s_type=${isRegularSeason ? 'regular' : 'post'}`)
const legacyPitchingStatsResponse: { const legacyPitchingStatsResponse: {
count: number count: number
@ -227,7 +227,7 @@ async function fetchLegacyPitchingStatsBySeasonAndPlayerId(seasonNumber: number,
} }
export async function fetchPitchingStatsForLastFourGamesBySeasonAndPlayerId(seasonNumber: number, playerId: number): Promise<PitchingStat[]> { export async function fetchPitchingStatsForLastFourGamesBySeasonAndPlayerId(seasonNumber: number, playerId: number): Promise<PitchingStat[]> {
const response = await fetch(`${SITE_URL}/api/v3/plays/pitching?season=${seasonNumber}&player_id=${playerId}&group_by=playergame&limit=4&s_type=regular&sort=newest`) const response = await fetch(`${API_URL}/plays/pitching?season=${seasonNumber}&player_id=${playerId}&group_by=playergame&limit=4&s_type=regular&sort=newest`)
const pitchingStatsResponse: { const pitchingStatsResponse: {
count: number count: number
@ -247,7 +247,7 @@ export async function fetchPitchingStatsForLastTwoWeeksByTeam(seasonNumber: numb
return [] return []
} }
const response = await fetch(`${SITE_URL}/api/v3/plays/pitching?season=${seasonNumber}&week_start=${weekNumber - 1}&week_end=${weekNumber}&team_id=${teamId}&group_by=playergame`) const response = await fetch(`${API_URL}/plays/pitching?season=${seasonNumber}&week_start=${weekNumber - 1}&week_end=${weekNumber}&team_id=${teamId}&group_by=playergame`)
const pitchingStatsResponse: { const pitchingStatsResponse: {
count: number count: number
@ -263,7 +263,7 @@ export async function fetchPitchingStatsBySeries(seasonNumber: number, weekNumbe
return [] return []
} }
const response = await fetch(`${SITE_URL}/api/v3/plays/pitching?season=${seasonNumber}&week=${weekNumber}&team_id=${homeTeamId}&team_id=${awayTeamId}&group_by=playergame`) const response = await fetch(`${API_URL}/plays/pitching?season=${seasonNumber}&week=${weekNumber}&team_id=${homeTeamId}&team_id=${awayTeamId}&group_by=playergame`)
const pitchingStatsResponse: { const pitchingStatsResponse: {
count: number count: number

View File

@ -1,5 +1,5 @@
import type { Team } from './apiResponseTypes' import type { Team } from './apiResponseTypes'
import { SITE_URL } from './utilities' import { API_URL } from './utilities'
export interface Player { export interface Player {
bbref_id: string bbref_id: string
@ -30,7 +30,7 @@ export interface Player {
} }
export async function fetchPlayers(seasonNumber: number): Promise<Player[]> { export async function fetchPlayers(seasonNumber: number): Promise<Player[]> {
const response = await fetch(`${SITE_URL}/api/v3/players?season=${seasonNumber}`) const response = await fetch(`${API_URL}/players?season=${seasonNumber}`)
const playersResponse: { const playersResponse: {
count: number count: number
@ -42,7 +42,7 @@ export async function fetchPlayers(seasonNumber: number): Promise<Player[]> {
// TODO should/can this use team abbrev instead of id? // TODO should/can this use team abbrev instead of id?
export async function fetchPlayersByTeam(seasonNumber: number, teamId: number): Promise<Player[]> { export async function fetchPlayersByTeam(seasonNumber: number, teamId: number): Promise<Player[]> {
const response = await fetch(`${SITE_URL}/api/v3/players?season=${seasonNumber}&team_id=${teamId}`) const response = await fetch(`${API_URL}/players?season=${seasonNumber}&team_id=${teamId}`)
const playersResponse: { const playersResponse: {
count: number count: number
@ -53,7 +53,7 @@ export async function fetchPlayersByTeam(seasonNumber: number, teamId: number):
} }
export async function fetchPlayerByName(seasonNumber: number, playerName: string): Promise<Player | undefined> { export async function fetchPlayerByName(seasonNumber: number, playerName: string): Promise<Player | undefined> {
const response = await fetch(`${SITE_URL}/api/v3/players?season=${seasonNumber}&name=${playerName}`) const response = await fetch(`${API_URL}/players?season=${seasonNumber}&name=${playerName}`)
const playersResponse: { const playersResponse: {
count: number count: number

View File

@ -1,5 +1,5 @@
import type { Team } from './apiResponseTypes' import type { Team } from './apiResponseTypes'
import { SITE_URL } from './utilities' import { API_URL } from './utilities'
interface TeamStandingRaw { interface TeamStandingRaw {
away_losses: number away_losses: number
@ -62,7 +62,7 @@ export interface TeamStanding {
} }
export async function fetchStandings(seasonNumber: number): Promise<TeamStanding[]> { export async function fetchStandings(seasonNumber: number): Promise<TeamStanding[]> {
const response = await fetch(`${SITE_URL}/api/v3/standings?season=${seasonNumber}`) const response = await fetch(`${API_URL}/standings?season=${seasonNumber}`)
const standingsResponse: { const standingsResponse: {
count: number count: number
@ -74,7 +74,7 @@ export async function fetchStandings(seasonNumber: number): Promise<TeamStanding
} }
export async function fetchStandingByTeam(team: Team): Promise<TeamStanding | undefined> { export async function fetchStandingByTeam(team: Team): Promise<TeamStanding | undefined> {
const response = await fetch(`${SITE_URL}/api/v3/standings?season=${team.season}`) const response = await fetch(`${API_URL}/standings?season=${team.season}`)
const standingsResponse: { const standingsResponse: {
count: number count: number

View File

@ -1,8 +1,8 @@
import type { Team } from './apiResponseTypes' import type { Team } from './apiResponseTypes'
import { CURRENT_SEASON, SITE_URL } from './utilities' import { CURRENT_SEASON, API_URL } from './utilities'
export async function fetchTeam(seasonNumber: number, teamAbbreviation: string): Promise<Team> { export async function fetchTeam(seasonNumber: number, teamAbbreviation: string): Promise<Team> {
const response = await fetch(`${SITE_URL}/api/v3/teams?season=${seasonNumber}&team_abbrev=${teamAbbreviation}`) const response = await fetch(`${API_URL}/teams?season=${seasonNumber}&team_abbrev=${teamAbbreviation}`)
const teamResponse: { const teamResponse: {
count: number count: number
@ -17,7 +17,7 @@ export async function fetchTeam(seasonNumber: number, teamAbbreviation: string):
} }
export async function fetchTeamsByManagerId(managerId: number): Promise<Team[]> { export async function fetchTeamsByManagerId(managerId: number): Promise<Team[]> {
const response = await fetch(`${SITE_URL}/api/v3/teams?manager_id=${managerId}`) const response = await fetch(`${API_URL}/teams?manager_id=${managerId}`)
const teamResponse: { const teamResponse: {
count: number count: number
@ -29,7 +29,7 @@ export async function fetchTeamsByManagerId(managerId: number): Promise<Team[]>
export async function fetchActiveTeamByOwnerId(ownerId: string): Promise<Team | undefined> { export async function fetchActiveTeamByOwnerId(ownerId: string): Promise<Team | undefined> {
const response = await fetch(`${SITE_URL}/api/v3/teams?season=${CURRENT_SEASON}&active_only=True&owner_id=${ownerId}`) const response = await fetch(`${API_URL}/teams?season=${CURRENT_SEASON}&active_only=True&owner_id=${ownerId}`)
const teamResponse: { const teamResponse: {
count: number count: number
@ -45,7 +45,7 @@ export async function fetchActiveTeamByOwnerId(ownerId: string): Promise<Team |
} }
export async function fetchTeamsBySeason(season: number): Promise<Team[]> { export async function fetchTeamsBySeason(season: number): Promise<Team[]> {
const response = await fetch(`${SITE_URL}/api/v3/teams?season=${season}&short_output=False`) const response = await fetch(`${API_URL}/teams?season=${season}&short_output=False`)
const teamResponse: { const teamResponse: {
count: number count: number

View File

@ -1,6 +1,6 @@
import type { Team } from './apiResponseTypes' import type { Team } from './apiResponseTypes'
import type { Player } from './playersService' import type { Player } from './playersService'
import { CURRENT_SEASON, SITE_URL } from './utilities' import { CURRENT_SEASON, API_URL } from './utilities'
export interface Transaction { export interface Transaction {
id: number id: number
@ -15,7 +15,7 @@ export interface Transaction {
} }
export async function fetchTransactionsByTeamAndWeek(seasonNumber: number, teamAbbreviation: string, weekNumber: number): Promise<Transaction[]> { export async function fetchTransactionsByTeamAndWeek(seasonNumber: number, teamAbbreviation: string, weekNumber: number): Promise<Transaction[]> {
const response = await fetch(`${SITE_URL}/api/v3/transactions?season=${seasonNumber}&team_abbrev=${teamAbbreviation}&week_start=${weekNumber}&week_end=${weekNumber}`) const response = await fetch(`${API_URL}/transactions?season=${seasonNumber}&team_abbrev=${teamAbbreviation}&week_start=${weekNumber}&week_end=${weekNumber}`)
const transactionsResponse: { const transactionsResponse: {
count: number count: number
@ -26,7 +26,7 @@ export async function fetchTransactionsByTeamAndWeek(seasonNumber: number, teamA
} }
export async function fetchTransactionsByWeek(seasonNumber: number, weekNumber: number): Promise<Transaction[]> { export async function fetchTransactionsByWeek(seasonNumber: number, weekNumber: number): Promise<Transaction[]> {
const response = await fetch(`${SITE_URL}/api/v3/transactions?season=${seasonNumber}&week_start=${weekNumber}&week_end=${weekNumber}`) const response = await fetch(`${API_URL}/transactions?season=${seasonNumber}&week_start=${weekNumber}&week_end=${weekNumber}`)
const transactionsResponse: { const transactionsResponse: {
count: number count: number
@ -37,7 +37,7 @@ export async function fetchTransactionsByWeek(seasonNumber: number, weekNumber:
} }
export async function fetchTransactionsForCurrentSeasonByPlayerName(playerName: string): Promise<Transaction[]> { export async function fetchTransactionsForCurrentSeasonByPlayerName(playerName: string): Promise<Transaction[]> {
const response = await fetch(`${SITE_URL}/api/v3/transactions?season=${CURRENT_SEASON}&player_name=${playerName}`) const response = await fetch(`${API_URL}/transactions?season=${CURRENT_SEASON}&player_name=${playerName}`)
const transactionsResponse: { const transactionsResponse: {
count: number count: number

View File

@ -4,6 +4,8 @@ dayjs.extend(customParseFormat)
export const SITE_URL = 'https://sba.manticorum.com' export const SITE_URL = 'https://sba.manticorum.com'
export const API_URL = 'https://api.sba.manticorum.com'
export const CURRENT_SEASON = 12 export const CURRENT_SEASON = 12
export const MODERN_STAT_ERA_START = 8 export const MODERN_STAT_ERA_START = 8