diff options
-rw-r--r-- | server.js | 28 | ||||
-rw-r--r-- | views/games_public.pug | 8 | ||||
-rw-r--r-- | views/info.pug | 10 |
3 files changed, 26 insertions, 20 deletions
@@ -1107,14 +1107,15 @@ const SQL_INSERT_REMATCH = SQL(` const QUERY_LIST_PUBLIC_GAMES = SQL(` SELECT * FROM game_view - WHERE is_private=0 AND status < 2 + WHERE is_private=0 AND status = ? AND EXISTS ( SELECT 1 FROM players WHERE players.game_id = game_view.game_id ) ORDER BY mtime DESC, ctime DESC + LIMIT ? `) const QUERY_LIST_GAMES_OF_TITLE = SQL(` SELECT * FROM game_view - WHERE is_private=0 AND title_id=? AND status>=? AND status<=? + WHERE is_private=0 AND title_id=? AND status=? AND EXISTS ( SELECT 1 FROM players WHERE players.game_id = game_view.game_id ) ORDER BY mtime DESC, ctime DESC LIMIT ? @@ -1296,14 +1297,17 @@ app.get('/games/finished/:who_name', function (req, res) { }) app.get('/games/public', function (req, res) { - let games = QUERY_LIST_PUBLIC_GAMES.all() + let games0 = QUERY_LIST_PUBLIC_GAMES.all(0, 1000) + let games1 = QUERY_LIST_PUBLIC_GAMES.all(1, 48) if (req.user) { let unread = SQL_SELECT_UNREAD_CHAT_GAMES.all(req.user.user_id) - annotate_games(games, req.user.user_id, unread) + annotate_games(games0, req.user.user_id, unread) + annotate_games(games1, req.user.user_id, unread) } else { - annotate_games(games, 0, null) + annotate_games(games0, 0, null) + annotate_games(games1, 0, null) } - res.render('games_public.pug', { user: req.user, games }) + res.render('games_public.pug', { user: req.user, games0, games1 }) }) app.get('/info/:title_id', function (req, res) { @@ -1317,15 +1321,17 @@ function get_title_page(req, res, title_id) { let unread = null if (req.user) unread = SQL_SELECT_UNREAD_CHAT_GAMES.all(req.user.user_id) - let active_games = QUERY_LIST_GAMES_OF_TITLE.all(title_id, 0, 1, 1000) - let finished_games = QUERY_LIST_GAMES_OF_TITLE.all(title_id, 2, 2, 50) - annotate_games(active_games, req.user ? req.user.user_id : 0, unread) - annotate_games(finished_games, req.user ? req.user.user_id : 0, unread) + let games0 = QUERY_LIST_GAMES_OF_TITLE.all(title_id, 0, 1000) + let games1 = QUERY_LIST_GAMES_OF_TITLE.all(title_id, 1, 1000) + let games2 = QUERY_LIST_GAMES_OF_TITLE.all(title_id, 2, 24) + annotate_games(games0, req.user ? req.user.user_id : 0, unread) + annotate_games(games1, req.user ? req.user.user_id : 0, unread) + annotate_games(games2, req.user ? req.user.user_id : 0, unread) res.render('info.pug', { user: req.user, title: title, about_html: HTML_ABOUT[title_id], - games: active_games.concat(finished_games) + games0, games1, games2 }) } diff --git a/views/games_public.pug b/views/games_public.pug index e1a5387..b91dd61 100644 --- a/views/games_public.pug +++ b/views/games_public.pug @@ -1,8 +1,8 @@ //- vim:ts=4:sw=4: -- let open_games = games.filter(game => game.status === 0 && !game.is_ready) -- let ready_games = games.filter(game => game.status === 0 && game.is_ready) -- let replacement_games = games.filter(game => game.status === 1 && !game.is_ready) -- let active_games = games.filter(game => game.status === 1 && game.is_ready) +- let open_games = games0.filter(game => game.status === 0 && !game.is_ready) +- let ready_games = games0.filter(game => game.status === 0 && game.is_ready) +- let replacement_games = games0.filter(game => game.status === 1 && !game.is_ready) +- let active_games = games1.filter(game => game.status === 1 && game.is_ready) doctype html html head diff --git a/views/info.pug b/views/info.pug index d60f79f..8eb1d40 100644 --- a/views/info.pug +++ b/views/info.pug @@ -1,9 +1,9 @@ //- vim:ts=4:sw=4: -- let open_games = games.filter(game => game.status === 0 && !game.is_ready) -- let ready_games = games.filter(game => game.status === 0 && game.is_ready) -- let replacement_games = games.filter(game => game.status === 1 && !game.is_ready) -- let active_games = games.filter(game => game.status === 1 && game.is_ready) -- let finished_games = games.filter(game => game.status === 2) +- let open_games = games0.filter(game => game.status === 0 && !game.is_ready) +- let ready_games = games0.filter(game => game.status === 0 && game.is_ready) +- let replacement_games = games1.filter(game => game.status === 1 && !game.is_ready) +- let active_games = games1.filter(game => game.status === 1 && game.is_ready) +- let finished_games = games2 doctype html html head |