From 3682e456846d14f827a2f736e08b93aba0076540 Mon Sep 17 00:00:00 2001 From: Tor Andersson Date: Tue, 5 Nov 2024 21:54:37 +0100 Subject: Improve tournament sorting order. --- schema.sql | 10 ++++++++-- server.js | 3 ++- views/head.pug | 2 +- views/tm_list.pug | 20 ++++---------------- 4 files changed, 15 insertions(+), 20 deletions(-) diff --git a/schema.sql b/schema.sql index 0ee91e2..e945916 100644 --- a/schema.sql +++ b/schema.sql @@ -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; diff --git a/server.js b/server.js index b9bc612..ce2dd38 100644 --- a/server.js +++ b/server.js @@ -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 tournament information. - 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, `${seed_name}`) -- cgit v1.2.3