diff options
author | Tor Andersson <tor@ccxvii.net> | 2024-11-05 21:54:37 +0100 |
---|---|---|
committer | Tor Andersson <tor@ccxvii.net> | 2024-11-05 21:54:37 +0100 |
commit | 3682e456846d14f827a2f736e08b93aba0076540 (patch) | |
tree | ff598ed6abc3a5e0e24c184fedd2c950d94247c6 | |
parent | 7986145f941bfb5a898c91eb175e3a740d663ea0 (diff) | |
download | server-3682e456846d14f827a2f736e08b93aba0076540.tar.gz |
Improve tournament sorting order.
-rw-r--r-- | schema.sql | 10 | ||||
-rw-r--r-- | server.js | 3 | ||||
-rw-r--r-- | views/head.pug | 2 | ||||
-rw-r--r-- | views/tm_list.pug | 20 |
4 files changed, 15 insertions, 20 deletions
@@ -636,9 +636,12 @@ drop view if exists tm_pool_active_view; create view tm_pool_active_view as select tm_pools.*, + tm_seeds.title_id, + tm_seeds.seed_name, sum(status > 1) || ' / ' || count(1) as status from tm_pools + join tm_seeds using(seed_id) left join tm_rounds using(pool_id) left join games using(game_id) where @@ -646,16 +649,19 @@ create view tm_pool_active_view as group by pool_id order by - pool_name + seed_name, level, pool_id ; drop view if exists tm_pool_finished_view; create view tm_pool_finished_view as select tm_pools.*, + tm_seeds.title_id, + tm_seeds.seed_name, group_concat(name) as status from tm_pools + join tm_seeds using(seed_id) left join tm_winners using(pool_id) left join users using(user_id) where @@ -663,7 +669,7 @@ create view tm_pool_finished_view as group by pool_id order by - pool_name + seed_name, level, pool_id ; drop view if exists tm_pool_view; @@ -2961,7 +2961,8 @@ app.get("/tm/list", function (req, res) { let seeds = TM_SEED_LIST_ALL.all(req.user ? req.user.user_id : 0) let seeds_by_title = object_group_by(seeds, "title_id") let active_pools = TM_POOL_LIST_ACTIVE.all() - res.render("tm_list.pug", { user: req.user, seeds, seeds_by_title, active_pools }) + let pools_by_seed = object_group_by(active_pools, "seed_name") + res.render("tm_list.pug", { user: req.user, seeds, seeds_by_title, active_pools, pools_by_seed }) }) app.get("/tm/seed/:seed_name", function (req, res) { diff --git a/views/head.pug b/views/head.pug index c3689c0..3792429 100644 --- a/views/head.pug +++ b/views/head.pug @@ -166,7 +166,7 @@ mixin poollist(list, title, icon) if title thead tr - th= title + th!= title td= icon tbody each pool in list diff --git a/views/tm_list.pug b/views/tm_list.pug index 4f7c147..bc7fd83 100644 --- a/views/tm_list.pug +++ b/views/tm_list.pug @@ -11,20 +11,8 @@ html p See <a href="/docs/tournaments.html">tournament information</a>. - if 0 - dl - each seeds, title_id in seeds_by_title - dt= TITLE_NAME[title_id] - each seed in seeds - dd - a(href="/tm/seed/" + seed.seed_name)= seed.seed_name - | (#{seed.queue_size}/#{seed.pool_size}) - if user && seed.is_queued - | 🎫 - if 0 - each seeds, title_id in seeds_by_title - +seedlist(seeds, TITLE_NAME[title_id]) - if 1 - +seedlist(seeds, "Mini Cup") + +seedlist(seeds, "Mini Cup") - +poollist(active_pools, "Active") + h2 Active + each pools, seed_name in pools_by_seed + +poollist(pools, `<a href="/tm/seed/${seed_name}">${seed_name}</a>`) |