update
This commit is contained in:
@@ -173,6 +173,7 @@ router.get("/games", async (req, res) => {
|
||||
* is_local: false
|
||||
* current_playing_user: 1
|
||||
* turn_order: null
|
||||
* creator: 1
|
||||
*/
|
||||
router.get("/games/:id", asyncHandler(async (req, res) => {
|
||||
const gameId = parseInt(req.params.id, 10);
|
||||
@@ -182,7 +183,7 @@ router.get("/games/:id", asyncHandler(async (req, res) => {
|
||||
if (!games.length) throw new ApiError(404, "Game not found");
|
||||
|
||||
const [creatorRows] = await pool.query(
|
||||
`SELECT u.id, u.username
|
||||
`SELECT u.id
|
||||
FROM game_players gp
|
||||
JOIN users u ON gp.user = u.id
|
||||
WHERE gp.game = ? AND gp.is_creator = TRUE
|
||||
@@ -190,7 +191,7 @@ router.get("/games/:id", asyncHandler(async (req, res) => {
|
||||
[gameId]
|
||||
);
|
||||
|
||||
const creator = creatorRows.lenght ? creatorRows[0] : null;
|
||||
const creator = creatorRows.length ? creatorRows[0].id : null;
|
||||
|
||||
res.json({ ...games[0], creator});
|
||||
}));
|
||||
@@ -388,7 +389,7 @@ router.patch("/games/:id/lock", asyncHandler(async (req, res) => {
|
||||
const currentPlayingUser = turnOrder[0];
|
||||
await conn.query(
|
||||
"UPDATE current_games SET is_open = FALSE, turn_order = ?, current_playing_user = ? WHERE id = ?",
|
||||
[JSON.stringify(turnOrder), gameId, currentPlayingUser]
|
||||
[JSON.stringify(turnOrder), currentPlayingUser, gameId]
|
||||
);
|
||||
|
||||
await conn.commit();
|
||||
|
||||
Reference in New Issue
Block a user