Season 9 update + make front page standings more generic
This commit is contained in:
parent
ffa76ceb99
commit
5f1bdbd34f
@ -37,6 +37,7 @@ export interface TeamStanding {
|
||||
season: number
|
||||
teamName: string
|
||||
teamAbbreviation: string
|
||||
divisionName: string
|
||||
divisionAbbreviation: string
|
||||
leagueAbbreviation: string
|
||||
wins: number
|
||||
@ -96,6 +97,7 @@ function normalizeStanding(standing: TeamStandingRaw): TeamStanding {
|
||||
season: standing.team.season,
|
||||
teamName: standing.team.sname,
|
||||
teamAbbreviation: standing.team.abbrev,
|
||||
divisionName: standing.team.division.division_name,
|
||||
divisionAbbreviation: standing.team.division.division_abbrev,
|
||||
leagueAbbreviation: standing.team.division.league_abbrev,
|
||||
wins: standing.wins,
|
||||
|
||||
@ -4,7 +4,7 @@ dayjs.extend(customParseFormat)
|
||||
|
||||
export const SITE_URL = 'https://sba.manticorum.com'
|
||||
|
||||
export const CURRENT_SEASON = 8
|
||||
export const CURRENT_SEASON = 9
|
||||
|
||||
export const MODERN_STAT_ERA_START = 8
|
||||
|
||||
@ -15,9 +15,9 @@ export const WEEKS_PER_SEASON = 18
|
||||
export const GAMES_PER_SEASON = GAMES_PER_WEEK * WEEKS_PER_SEASON
|
||||
|
||||
// TODO: Annually update this start date and holidays with two week series or get it from the DB
|
||||
export const SEASON_START_DATE: dayjs.Dayjs = dayjs('07-31-2023', 'MM/DD/YYYY')
|
||||
export const THANKSGIVING: dayjs.Dayjs = dayjs('11-23-2023', 'MM/DD/YYYY')
|
||||
export const CHRISTMAS: dayjs.Dayjs = dayjs('12-25-2023', 'MM/DD/YYYY')
|
||||
export const SEASON_START_DATE: dayjs.Dayjs = dayjs('01-15-2024', 'MM/DD/YYYY')
|
||||
export const THANKSGIVING: dayjs.Dayjs = dayjs('11-28-2024', 'MM/DD/YYYY')
|
||||
export const CHRISTMAS: dayjs.Dayjs = dayjs('12-25-2024', 'MM/DD/YYYY')
|
||||
|
||||
|
||||
export const POS_MAP = {
|
||||
|
||||
@ -16,14 +16,12 @@
|
||||
<div class="row">
|
||||
<div class="col-md-6">
|
||||
<h2>SBa League</h2>
|
||||
<h3>International wOBA Grand Prix</h3>
|
||||
<StandingsTable :teams="iwgpTeams" :is-divisional=true />
|
||||
<h3>Crabbers</h3>
|
||||
<StandingsTable :teams="balTeams" :is-divisional=true />
|
||||
<h3>Fun Diff</h3>
|
||||
<StandingsTable :teams="fdTeams" :is-divisional=true />
|
||||
<h3>NL West</h3>
|
||||
<StandingsTable :teams="nlwTeams" :is-divisional=true />
|
||||
<template v-if="standingsByDivision.length && standingsByDivision[0].length">
|
||||
<template v-for="division in standingsByDivision" :key="division[0].divisionName">
|
||||
<h3>{{ division[0].divisionName }}</h3>
|
||||
<StandingsTable :teams="division" :is-divisional=true />
|
||||
</template>
|
||||
</template>
|
||||
<h3>Wildcard</h3>
|
||||
<StandingsTable :teams="wildcardTeams" :is-divisional=false />
|
||||
</div>
|
||||
@ -60,11 +58,8 @@ export default {
|
||||
seasonNumber: CURRENT_SEASON as number,
|
||||
weekNumber: undefined as number | undefined,
|
||||
teamStandings: [] as TeamStanding[],
|
||||
iwgpTeams: [] as TeamStanding[],
|
||||
nlwTeams: [] as TeamStanding[],
|
||||
wildcardTeams: [] as TeamStanding[],
|
||||
balTeams: [] as TeamStanding[],
|
||||
fdTeams: [] as TeamStanding[],
|
||||
standingsByDivision: [[]] as TeamStanding[][],
|
||||
newsPosts: [] as NewsPost[]
|
||||
}
|
||||
},
|
||||
@ -77,15 +72,18 @@ export default {
|
||||
this.weekNumber = leagueInfo.week
|
||||
|
||||
this.teamStandings = await fetchStandings(CURRENT_SEASON)
|
||||
// TODO this could be made more robust to division/league structure changes by identifying the unique
|
||||
// league/div abbreviations, then grouping on each into an array of arrays, then in the template above
|
||||
// v-for over the structure to generate a dynamic standings page
|
||||
this.iwgpTeams = this.teamStandings.filter(ts => ts.divisionAbbreviation === 'IWGP')
|
||||
this.nlwTeams = this.teamStandings.filter(ts => ts.divisionAbbreviation === 'NLW')
|
||||
this.balTeams = this.teamStandings.filter(ts => ts.divisionAbbreviation === 'BAL')
|
||||
this.fdTeams = this.teamStandings.filter(ts => ts.divisionAbbreviation === 'FD')
|
||||
this.wildcardTeams = this.teamStandings.filter(ts => ts.isWildcardTeam)
|
||||
|
||||
const teamStandingsByDivisionAbbreviation: { [key: string]: TeamStanding[] } = {}
|
||||
this.teamStandings.forEach(ts => {
|
||||
if (!teamStandingsByDivisionAbbreviation[ts.divisionAbbreviation]) {
|
||||
teamStandingsByDivisionAbbreviation[ts.divisionAbbreviation] = []
|
||||
}
|
||||
teamStandingsByDivisionAbbreviation[ts.divisionAbbreviation].push(ts)
|
||||
})
|
||||
|
||||
this.standingsByDivision = Object.values(teamStandingsByDivisionAbbreviation)
|
||||
|
||||
this.newsPosts = await getPosts()
|
||||
},
|
||||
|
||||
|
||||
@ -7,9 +7,9 @@
|
||||
<!-- TODO this will be dynamic based on batting vs pitching -->
|
||||
<h2 id="stat-heading">{{ statType }} Leaderboards - Min {{ statMinimum }}</h2>
|
||||
<!-- <label for="seasonNumber">Select Season</label> -->
|
||||
<!-- <select name="seasonNumber" id="seasonNumber" v-model="seasonNumber">
|
||||
<select name="seasonNumber" id="seasonNumber" v-model="seasonNumber">
|
||||
<option v-for="season in seasonNumbers" :key="season" :value="season">Season {{ season }}</option>
|
||||
</select> -->
|
||||
</select>
|
||||
<!-- TODO ADD SORT FOR ASC/DESC -->
|
||||
<select name="statType" id="statType" v-model="statType">
|
||||
<option key="Batting" value="Batting">Batting</option>
|
||||
@ -63,7 +63,7 @@ import { fetchFieldingStatsBySeason, type FieldingStat } from '@/services/fieldi
|
||||
import { fetchPitchingStatsBySeason, type PitchingStat } from '@/services/pitchingStatsService'
|
||||
import type { Player } from '@/services/playersService'
|
||||
import { fetchTeamsBySeason } from '@/services/teamsService'
|
||||
import { CURRENT_SEASON, GAMES_PER_WEEK, WEEKS_PER_SEASON } from '@/services/utilities'
|
||||
import { CURRENT_SEASON, GAMES_PER_WEEK, MODERN_STAT_ERA_START, WEEKS_PER_SEASON } from '@/services/utilities'
|
||||
|
||||
interface LeaderboardTableData<T> {
|
||||
title: string
|
||||
@ -120,11 +120,12 @@ export default {
|
||||
computed: {
|
||||
seasonNumbers(): number[] {
|
||||
if (!this.currentSeasonNumber) return []
|
||||
return Array.from({ length: this.currentSeasonNumber }, (_, i) => i + 1)
|
||||
return Array.from({ length: this.currentSeasonNumber - MODERN_STAT_ERA_START + 1 }, (_, i) => i + MODERN_STAT_ERA_START)
|
||||
},
|
||||
weekNumberForCalcs(): number {
|
||||
if (this.seasonNumber < this.currentSeasonNumber) return WEEKS_PER_SEASON
|
||||
// since stats are for regular season, do not use post season weeks to up PA/IP mins
|
||||
return Math.min(this.weekNumber, WEEKS_PER_SEASON)
|
||||
return Math.max(0, Math.min(this.weekNumber, WEEKS_PER_SEASON))
|
||||
},
|
||||
statMinimum(): string {
|
||||
if (this.statType == 'Batting') return `PA: ${this.plateAppearanceMinimum}`
|
||||
|
||||
Loading…
Reference in New Issue
Block a user