Skip to content

Commit

Permalink
fix build error
Browse files Browse the repository at this point in the history
  • Loading branch information
tobyrushton committed Sep 28, 2024
1 parent 05d650b commit 55fbdfd
Show file tree
Hide file tree
Showing 4 changed files with 21 additions and 9 deletions.
6 changes: 5 additions & 1 deletion __tests__/integration/update-game-stats.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,11 @@ describe('updateGameStats', () => {
it('should add game stats when none are in db', async () => {
// if season hasn't started yet, this will be 0
// so skip test
if (getCurrentSeason() > new Date().getFullYear() && new Date().getMonth() < 11) return
if (
getCurrentSeason() > new Date().getFullYear() &&
new Date().getMonth() < 11
)
return
await updateGameStats()

const count = await prisma.playerGame.count()
Expand Down
8 changes: 6 additions & 2 deletions __tests__/integration/update-season-average.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,12 @@ describe('updateSeasonAverages', () => {
it('should update season averages when none are in db', async () => {
// if season hasn't started yet, this will be 0
// so skip test
if (getCurrentSeason() > new Date().getFullYear() && new Date().getMonth() < 11) return

if (
getCurrentSeason() > new Date().getFullYear() &&
new Date().getMonth() < 11
)
return

const playerCount = await prisma.player.count()
await updateSeasonAverages()

Expand Down
2 changes: 1 addition & 1 deletion src/components/Roster.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ const RosterItemSkeleton: FC = () => {
}

const RosterItem: FC<RosterItemProps> = async ({ player }) => {
let average: player.ISeasonAverage | undefined
let average: player.ISeasonAverage | undefined | null

try {
average = (await serverClient.getSeasonAverage({ id: player.id }))
Expand Down
14 changes: 9 additions & 5 deletions src/server/functions/update-schedule.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,20 +15,24 @@ export const updateSchedule = async (): Promise<void> => {
])

const newGamesNotInDb = schedule.filter(
game =>
!scheduleInDb.some(gameInDb => game.date === gameInDb.date)
game => !scheduleInDb.some(gameInDb => game.date === gameInDb.date)
)

const gamesToUpdate = schedule.filter(game =>
scheduleInDb.some(
gameInDb =>
sameDay(gameInDb.date, game.date) &&
!scheduleGameIsEqual(game, gameInDb)
&& game.opponent_name === gameInDb.opponent.name
!scheduleGameIsEqual(game, gameInDb) &&
game.opponent_name === gameInDb.opponent.name
)
)

console.log(schedule.length, newGamesNotInDb.length, gamesToUpdate.length, scheduleInDb.length)
console.log(
schedule.length,
newGamesNotInDb.length,
gamesToUpdate.length,
scheduleInDb.length
)

if (gamesToUpdate.length > 0)
await Promise.all(
Expand Down

0 comments on commit 55fbdfd

Please sign in to comment.