summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTor Andersson <tor@ccxvii.net>2024-04-13 19:26:17 +0200
committerTor Andersson <tor@ccxvii.net>2024-04-13 19:26:17 +0200
commitd851f5b1253d1463f0c68955f2da646b9118ee27 (patch)
treed9e83fc8e3c1ebb68cb5a740fd63c45255a9650e
parent71e3087f5a8382a38b0780758b4b9b44230e8c98 (diff)
downloadserver-d851f5b1253d1463f0c68955f2da646b9118ee27.tar.gz
WIP show some stats
-rw-r--r--server.js21
1 files changed, 11 insertions, 10 deletions
diff --git a/server.js b/server.js
index e9baf8d..d2b52f4 100644
--- a/server.js
+++ b/server.js
@@ -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