diff --git a/database/scores/games.js b/database/scores/games.js index e01352c..4c5b22e 100644 --- a/database/scores/games.js +++ b/database/scores/games.js @@ -41,14 +41,14 @@ async function retrieve(teamID, divisionID, seasonID) { let table; if(teamID && divisionID && seasonID) { - const query = `SELECT game_id, division_id, season_id, game_date, team1_id, team2_id, team1_score, team2_score + const query = `SELECT game_id, division_id, season_id, game_date, team1_id, team2_id, team1_score, team2_score, submitter_id FROM scores.games WHERE (team1_id = $1 OR team2_id = $1) AND division_id = $2 AND season_id = $3 ORDER BY game_date DESC;`; table = await database.executeQuery(query, [teamID,divisionID,seasonID]); } else { - const query = `SELECT game_id, division_id, season_id, game_date, team1_id, team2_id, team1_score, team2_score + const query = `SELECT game_id, division_id, season_id, game_date, team1_id, team2_id, team1_score, team2_score, submitter_id FROM scores.games ORDER BY game_date DESC;`; table = await database.executeQuery(query); @@ -63,10 +63,10 @@ async function retrieve(teamID, divisionID, seasonID) { 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])); + gamesList.push(new Game(row[0], row[3].toISOString().slice(0,10), teamID, opponentID, teamScore, opponentScore, row[1], row[2], row[8])); } 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])); + gamesList.push(new Game(row[0], row[3].toISOString().slice(0,10), row[4], row[5], row[6], row[7], row[1], row[2], row[8])); } }); return gamesList; diff --git a/public/scripts/manage.js b/public/scripts/manage.js index f6fd2fe..2b958f9 100644 --- a/public/scripts/manage.js +++ b/public/scripts/manage.js @@ -232,6 +232,10 @@ CATEGORIES.push(new Category( dateHeader.textContent = "Date"; headerRow.appendChild(dateHeader); + const submitterHeader = document.createElement('th'); + submitterHeader.textContent = "Submitter"; + headerRow.appendChild(submitterHeader); + itemsListTable.appendChild(headerRow); }, function listGame(game, row) { @@ -285,6 +289,11 @@ CATEGORIES.push(new Category( dateSpan.textContent = game.date.slice(5); dateCell.appendChild(dateSpan); row.appendChild(dateCell); + + const submitterCell = document.createElement('td'); + Data.getAccount(game.submitterID) + .then(data => submitterCell.textContent = data.name); + row.appendChild(submitterCell); }, async function addGame() { window.location.href = "/manage/game";