From fe659184f41838ec53313d7d9b9ef84eee3f426b Mon Sep 17 00:00:00 2001 From: sudoer777 <78781902+sudoer777@users.noreply.github.com> Date: Mon, 22 Nov 2021 16:13:21 -0700 Subject: [PATCH] Fix bug in games.js --- database/scores/games.js | 17 +++++++++++------ 1 file changed, 11 insertions(+), 6 deletions(-) diff --git a/database/scores/games.js b/database/scores/games.js index 9f27bab..4055523 100644 --- a/database/scores/games.js +++ b/database/scores/games.js @@ -58,12 +58,17 @@ async function retrieve(teamID, divisionID, seasonID) { const gamesList = []; table.forEach((row) => { - opponentIsTeam2 = teamID != row[5]; - opponentID = opponentIsTeam2 ? row[5] : row[4]; - teamScore = opponentIsTeam2 ? row[6] : row[7]; - opponentScore = opponentIsTeam2 ? row[7] : row[6]; - - gamesList.push(new Game(row[0], row[3].toISOString().slice(0,10), teamID, opponentID, teamScore, opponentScore, row[1], row[2])); + if(teamID) { + const opponentIsTeam2 = teamID != row[5]; + const opponentID = opponentIsTeam2 ? row[5] : row[4]; + const teamScore = opponentIsTeam2 ? row[6] : row[7]; + const opponentScore = opponentIsTeam2 ? row[7] : row[6]; + + gamesList.push(new Game(row[0], row[3].toISOString().slice(0,10), teamID, opponentID, teamScore, opponentScore, row[1], row[2])); + } + else { + gamesList.push(new Game(row[0], row[3].toISOString().slice(0,10), row[4], row[5], row[6], row[7], row[1], row[2])); + } }); return gamesList; }