Fetch adjacent games
This commit is contained in:
parent
308dc47000
commit
e823ba8ff2
@ -351,11 +351,18 @@ import type { Game, Team } from '@/services/apiResponseTypes'
|
||||
import { isDiscordAuthenticated } from '@/services/authenticationService'
|
||||
import { fetchBattingStatsBySeries, type BattingStat } from '@/services/battingStatsService'
|
||||
import { fetchFieldingStatsBySeries, type FieldingStat } from '@/services/fieldingStatsService'
|
||||
import { fetchSingleGame } from '@/services/gameService'
|
||||
import { fetchGamesBySeasonAndTeamId, fetchSingleGame } from '@/services/gameService'
|
||||
import { fetchPitchingStatsBySeries, type PitchingStat } from '@/services/pitchingStatsService'
|
||||
import { fetchTeam } from '@/services/teamsService'
|
||||
import { outsToInnings } from '@/services/utilities'
|
||||
|
||||
interface AdjacentGameHelper {
|
||||
team1prevGame: Game
|
||||
team1nextGame: Game
|
||||
team2prevGame: Game
|
||||
team2nextGame: Game
|
||||
}
|
||||
|
||||
export default {
|
||||
name: 'GameView',
|
||||
data() {
|
||||
@ -367,6 +374,7 @@ export default {
|
||||
battingStats: [] as BattingStat[],
|
||||
pitchingStats: [] as PitchingStat[],
|
||||
fieldingStats: [] as FieldingStat[],
|
||||
adjacentGames: undefined as AdjacentGameHelper | undefined,
|
||||
}
|
||||
},
|
||||
props: {
|
||||
@ -457,7 +465,6 @@ export default {
|
||||
decisionStrings.push(`Blown Save${blownSaves.length > 1 ? 's' : ''}: ${blownSaves.map(h => h.player.name).join(', ')}`)
|
||||
}
|
||||
|
||||
|
||||
return decisionStrings.join(' | ')
|
||||
}
|
||||
},
|
||||
@ -477,6 +484,25 @@ export default {
|
||||
this.battingStats = await fetchBattingStatsBySeries(this.seasonNumber, this.weekNumber, this.team1.id, this.team2.id)
|
||||
this.pitchingStats = await fetchPitchingStatsBySeries(this.seasonNumber, this.weekNumber, this.team1.id, this.team2.id)
|
||||
this.fieldingStats = await fetchFieldingStatsBySeries(this.seasonNumber, this.weekNumber, this.team1.id, this.team2.id)
|
||||
|
||||
await this.fetchAdjacentGames()
|
||||
},
|
||||
async fetchAdjacentGames(): Promise<void> {
|
||||
const team1Games = await fetchGamesBySeasonAndTeamId(this.seasonNumber, this.team1!.id)
|
||||
const team2Games = await fetchGamesBySeasonAndTeamId(this.seasonNumber, this.team2!.id)
|
||||
|
||||
const prevGameNumber = this.gameNumber === 1 ? 4 : this.gameNumber - 1
|
||||
const nextGameNumber = this.gameNumber === 4 ? 1 : this.gameNumber + 1
|
||||
|
||||
const prevWeekNumber = this.gameNumber === 1 ? this.weekNumber - 1 : this.weekNumber
|
||||
const nextWeekNumber = this.gameNumber === 4 ? this.weekNumber + 1 : this.weekNumber
|
||||
|
||||
this.adjacentGames = {
|
||||
team1nextGame: team1Games.find(g => g.week === nextWeekNumber && g.game_num === nextGameNumber)!,
|
||||
team1prevGame: team1Games.find(g => g.week === prevWeekNumber && g.game_num === prevGameNumber)!,
|
||||
team2nextGame: team2Games.find(g => g.week === nextWeekNumber && g.game_num === nextGameNumber)!,
|
||||
team2prevGame: team2Games.find(g => g.week === prevWeekNumber && g.game_num === prevGameNumber)!
|
||||
}
|
||||
},
|
||||
outsToInnings(stat: PitchingStat): string {
|
||||
return outsToInnings(stat)
|
||||
|
||||
Loading…
Reference in New Issue
Block a user