diff options
author | Tor Andersson <tor@ccxvii.net> | 2024-04-13 19:26:17 +0200 |
---|---|---|
committer | Tor Andersson <tor@ccxvii.net> | 2024-04-13 19:26:17 +0200 |
commit | d851f5b1253d1463f0c68955f2da646b9118ee27 (patch) | |
tree | d9e83fc8e3c1ebb68cb5a740fd63c45255a9650e | |
parent | 71e3087f5a8382a38b0780758b4b9b44230e8c98 (diff) | |
download | server-d851f5b1253d1463f0c68955f2da646b9118ee27.tar.gz |
WIP show some stats
-rw-r--r-- | server.js | 21 |
1 files changed, 11 insertions, 10 deletions
@@ -684,17 +684,27 @@ app.post("/change-about", must_be_logged_in, function (req, res) { return res.redirect("/profile") }) +const SQL_USER_RATINGS = SQL(` + select title_name, rating, count, date(last) as last + from ratings + join titles using(title_id) + where user_id = ? + and count > 0 + --order by count desc + `) + app.get("/user/:who_name", function (req, res) { let who = SQL_SELECT_USER_PROFILE.get(req.params.who_name) if (who) { who.ctime = human_date(who.ctime) who.atime = human_date(who.atime) 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 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 }) + res.render("user.pug", { user: req.user, who, relation, games, ratings }) } else { return res.status(404).send("Invalid user name.") } @@ -3179,15 +3189,6 @@ const SQL_USER_STATS = SQL(` scenario `) -const SQL_USER_RATINGS = SQL(` - select 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 - `) - const SQL_GAME_RATINGS = SQL(` select name, rating, count, date(last) as last from ratings |