Centralize constants

This commit is contained in:
Peter 2023-10-31 16:08:14 -04:00
parent 4750bb5f00
commit 7e49b96f92
2 changed files with 11 additions and 22 deletions

View File

@ -1,3 +1,7 @@
import dayjs from 'dayjs'
import customParseFormat from 'dayjs/plugin/customParseFormat'
dayjs.extend(customParseFormat)
export const SITE_URL = 'https://sba.manticorum.com'
export const CURRENT_SEASON = 8
@ -8,6 +12,12 @@ export const GAMES_PER_SEASON = 72
export const WEEKS_PER_SEASON = 18
// 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 POS_MAP = {
'P': 1,
'C': 2,

View File

@ -105,7 +105,7 @@
<script lang="ts">
import type { Game } from '@/services/apiResponseTypes'
import { type LeagueInfo, fetchCurrentLeagueInfo } from '@/services/currentService'
import { CURRENT_SEASON, WEEKS_PER_SEASON } from '@/services/utilities'
import { CHRISTMAS, CURRENT_SEASON, SEASON_START_DATE, THANKSGIVING, WEEKS_PER_SEASON } from '@/services/utilities'
import { fetchGamesBySeasonAndWeek } from '@/services/gameService'
import dayjs from 'dayjs'
import customParseFormat from 'dayjs/plugin/customParseFormat'
@ -118,11 +118,6 @@ interface ScheduleWeekRow {
weekSpecialInfo: string
}
// TODO: Annually update this start date and holidays with two week series or get it from the DB
const SEASON_START_DATE: dayjs.Dayjs = dayjs('07-31-2023', 'MM/DD/YYYY')
const THANKSGIVING: dayjs.Dayjs = dayjs('11-23-2023', 'MM/DD/YYYY')
const CHRISTMAS: dayjs.Dayjs = dayjs('12-25-2023', 'MM/DD/YYYY')
export default {
name: 'ScheduleView',
data() {
@ -207,22 +202,6 @@ export default {
|| Math.abs(weekStartDate.diff(THANKSGIVING, 'days')) < 6
|| Math.abs(weekStartDate.diff(CHRISTMAS, 'days')) < 6
},
weekStart(weekNumber: number): string {
// Only WS week gets delayed by LCS
if (weekNumber === 21) {
return SEASON_START_DATE.add(weekNumber * 7, 'd').format('MM/DD/YYYY')
}
return SEASON_START_DATE.add((weekNumber - 1) * 7, 'd').format('MM/DD/YYYY')
},
weekEnd(weekNumber: number): string {
// LCS and WS end 13 days after start date
if (weekNumber >= 20) {
return dayjs(this.weekStart(weekNumber)).add(13, 'd').format('MM/DD/YYYY')
}
return SEASON_START_DATE.add((weekNumber * 7) - 1, 'd').format('MM/DD/YYYY')
},
weekSpecialInfo(weekNumber: number): string {
if (weekNumber === 1) return 'Spring Begins'
if (weekNumber === 6) return 'Summer Begins'