summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTor Andersson <tor@ccxvii.net>2022-01-27 01:05:11 +0100
committerTor Andersson <tor@ccxvii.net>2022-01-27 01:05:35 +0100
commited0e6a2ae0dee1e9eb26466d0ffaaf73a3cdf445 (patch)
tree4044fe43210deda3371c1d4c1dfcbd587b927671
parent3995598069f086594c539fca75aee583861b9406 (diff)
downloadserver-ed0e6a2ae0dee1e9eb26466d0ffaaf73a3cdf445.tar.gz
Show user stats per-role.
-rw-r--r--server.js4
-rw-r--r--views/user_stats.pug12
2 files changed, 11 insertions, 5 deletions
diff --git a/server.js b/server.js
index c288bc3..5cd511c 100644
--- a/server.js
+++ b/server.js
@@ -265,6 +265,7 @@ const SQL_USER_STATS = SQL(`
select
title_name,
scenario,
+ role,
sum(role=result) as won,
count(*) as total
from
@@ -277,7 +278,8 @@ const SQL_USER_STATS = SQL(`
and game_id in (select game_id from opposed_games)
group by
title_name,
- scenario
+ scenario,
+ role
`);
function is_blacklisted(mail) {
diff --git a/views/user_stats.pug b/views/user_stats.pug
index 70211ef..865e7fd 100644
--- a/views/user_stats.pug
+++ b/views/user_stats.pug
@@ -6,7 +6,7 @@ html
head
include head
title Stats for #{who.name}
- style td:nth-child(3),td:nth-child(4){text-align:right}
+ style td:nth-child(n+4){text-align:right}
body
include header
article
@@ -16,23 +16,27 @@ html
tr
th Title
th Scenario
+ th Role
+ th Played
th Won
- th Total
each row in stats
tr
- all_won += row.won
- all_total += row.total
td= row.title_name
td= row.scenario
- td= row.won
+ td= row.role
td= row.total
+ td= Math.round(row.won*100/row.total) + "%"
tr
th
th
th
th
+ th
tr
td
td
- td= Math.round(all_won * 100 / all_total) + "%"
+ td
td= all_total
+ td= Math.round(all_won*100/all_total) + "%"