From 3682e456846d14f827a2f736e08b93aba0076540 Mon Sep 17 00:00:00 2001
From: Tor Andersson <tor@ccxvii.net>
Date: Tue, 5 Nov 2024 21:54:37 +0100
Subject: Improve tournament sorting order.

---
 schema.sql | 10 ++++++++--
 1 file changed, 8 insertions(+), 2 deletions(-)

(limited to 'schema.sql')

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;
-- 
cgit v1.2.3

