summaryrefslogtreecommitdiff
path: root/server.js
diff options
context:
space:
mode:
authorTor Andersson <tor@ccxvii.net>2025-02-12 00:43:30 +0100
committerTor Andersson <tor@ccxvii.net>2025-02-14 12:27:41 +0100
commitea5ee6b976dedc1ac54d7fb71473db0131d735be (patch)
tree052afd30d305d11e0f572fcbf0ecdb1f5857f0bb /server.js
parent0b9c2f44c58f7750f03f218da8c2444cb8c987f7 (diff)
downloadserver-ea5ee6b976dedc1ac54d7fb71473db0131d735be.tar.gz
Show play stats on user pages.
Timeout and move time. Most played games.
Diffstat (limited to 'server.js')
-rw-r--r--server.js17
1 files changed, 13 insertions, 4 deletions
diff --git a/server.js b/server.js
index 98f4164..3faa6b0 100644
--- a/server.js
+++ b/server.js
@@ -827,13 +827,22 @@ app.get("/user/:who_name", function (req, res) {
let who = SQL_SELECT_USER_PROFILE.get(req.params.who_name)
if (who) {
let games = QUERY_LIST_PUBLIC_GAMES_OF_USER.all({ user_id: who.user_id })
+ let ratings = SQL_USER_RATINGS.all(who.user_id)
annotate_games(games, 0, null)
let active_pools = TM_POOL_LIST_USER_ACTIVE.all(who.user_id)
let finished_pools = TM_POOL_LIST_USER_RECENT_FINISHED.all(who.user_id)
let relation = 0
if (req.user)
relation = SQL_SELECT_RELATION.get(req.user.user_id, who.user_id) | 0
- res.render("user.pug", { user: req.user, who, relation, games, active_pools, finished_pools })
+ res.render("user.pug", {
+ user: req.user,
+ who,
+ relation,
+ games,
+ active_pools,
+ finished_pools,
+ ratings,
+ })
} else {
return res.status(404).send("User not found.")
}
@@ -4189,12 +4198,12 @@ const SQL_USER_STATS = SQL(`
`)
const SQL_USER_RATINGS = SQL(`
- select title_name, rating, count, date(last) as last
+ select title_id, title_name, rating, count, date(last) as last
from ratings
join titles using(title_id)
where user_id = ?
- and count >= 5
- order by rating desc
+ and count >= 3
+ order by count desc
`)
const SQL_GAME_RATINGS = SQL(`