diff --git a/components.d.ts b/components.d.ts index 3bdcdd8..2aa0cfb 100644 --- a/components.d.ts +++ b/components.d.ts @@ -9,6 +9,7 @@ export {} declare module '@vue/runtime-core' { export interface GlobalComponents { + BullpenTable: typeof import('./src/components/BullpenTable.vue')['default'] CardImagesDisplay: typeof import('./src/components/CardImagesDisplay.vue')['default'] ExtendedStandingsTable: typeof import('./src/components/ExtendedStandingsTable.vue')['default'] IconCommunity: typeof import('./src/components/icons/IconCommunity.vue')['default'] diff --git a/src/components/BullpenTable.vue b/src/components/BullpenTable.vue new file mode 100644 index 0000000..d4a3ede --- /dev/null +++ b/src/components/BullpenTable.vue @@ -0,0 +1,126 @@ + + + diff --git a/src/components/PlayerCareerBattingTable.vue b/src/components/PlayerCareerBattingTable.vue index 882a677..026452f 100644 --- a/src/components/PlayerCareerBattingTable.vue +++ b/src/components/PlayerCareerBattingTable.vue @@ -36,7 +36,7 @@ - + S{{ stat.seasonNumber }}{{ stat.isRegularSeason ? '' : ' / Playoffs' }} {{ stat.pa }} {{ stat.ab }} @@ -67,7 +67,7 @@ - + Career{{ idx > 0 ? ' / Playoffs' : '' }} {{ stat.pa }} {{ stat.ab }} @@ -112,7 +112,7 @@ interface BattingStatWithSeason extends BattingStat { } export default { - name: "PlayerCareerBattingTable", + name: 'PlayerCareerBattingTable', props: { regularSeasonBattingStats: { type: Array, required: true }, postSeasonBattingStats: { type: Array, required: true }, diff --git a/src/services/pitchingStatsService.ts b/src/services/pitchingStatsService.ts index 9ab0f79..cb9405a 100644 --- a/src/services/pitchingStatsService.ts +++ b/src/services/pitchingStatsService.ts @@ -241,6 +241,22 @@ export async function fetchPitchingStatsForLastFourGamesBySeasonAndPlayerId(seas return pitchingStatsResponse.stats.map(normalizePitchingStat) } +export async function fetchPitchingStatsForLastTwoWeeksByTeam(seasonNumber: number, weekNumber: number, teamId: number): Promise { + // no support for pre-modern games yet + if (seasonNumber < MODERN_STAT_ERA_START) { + 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 pitchingStatsResponse: { + count: number + stats: PitchingStatRaw[] + } = await response.json() + + return pitchingStatsResponse.stats.map(normalizePitchingStat) +} + export async function fetchPitchingStatsBySeries(seasonNumber: number, weekNumber: number, homeTeamId: number, awayTeamId: number): Promise { // no support for pre-modern games yet if (seasonNumber < MODERN_STAT_ERA_START) { @@ -251,10 +267,10 @@ export async function fetchPitchingStatsBySeries(seasonNumber: number, weekNumbe const pitchingStatsResponse: { count: number - stats: PitchingStat[] + stats: PitchingStatRaw[] } = await response.json() - return pitchingStatsResponse.stats + return pitchingStatsResponse.stats.map(normalizePitchingStat) } export function aggregatePitchingStats(pitchingStats: PitchingStat[]): PitchingStat { diff --git a/src/views/TeamView.vue b/src/views/TeamView.vue index d346110..fbd359c 100644 --- a/src/views/TeamView.vue +++ b/src/views/TeamView.vue @@ -155,6 +155,8 @@ + + @@ -191,10 +193,12 @@ import TeamScheduleTable from '@/components/TeamScheduleTable.vue' import TeamPitchingTable from '@/components/TeamPitchingTable.vue' import TeamBattingTable from '@/components/TeamBattingTable.vue' import TeamFieldingTable from '@/components/TeamFieldingTable.vue' +import BullpenTable from '@/components/BullpenTable.vue' export default { name: 'TeamView', components: { + BullpenTable, TeamScheduleTable, TeamPitchingTable, TeamBattingTable, @@ -309,7 +313,7 @@ export default { allPositions(player: Player): string { let positions = [] positions.push(player.pos_1, player.pos_2, player.pos_3, player.pos_4, player.pos_5, player.pos_6, player.pos_7) - return positions.join(' ') + return positions.filter(p => p).join(' ') }, swarTotal(players: Player[]): number { return players.map(p => p.wara).reduce((prev, curr) => prev + curr, 0) diff --git a/src/views/TransactionsView.vue b/src/views/TransactionsView.vue index 0d03b0f..3982206 100644 --- a/src/views/TransactionsView.vue +++ b/src/views/TransactionsView.vue @@ -150,9 +150,7 @@ export default { }, async fetchData(): Promise { this.weekTransactions = await fetchTransactionsByWeek(this.seasonNumber, this.selectedWeekNumber) - console.log('curr', this.weekTransactions) this.nextWeekTransactions = await fetchTransactionsByWeek(this.seasonNumber, this.selectedWeekNumber + 1) - console.log('next', this.nextWeekTransactions) } } }