diff options
author | Tor Andersson <tor@ccxvii.net> | 2024-11-03 23:57:05 +0100 |
---|---|---|
committer | Tor Andersson <tor@ccxvii.net> | 2024-11-03 23:57:05 +0100 |
commit | 1172b452e371ba79fe3e5e2f28e23c7f67735771 (patch) | |
tree | 36f5c7e4c904441d675977cb61dbaa2c01fc01d7 /server.js | |
parent | 4893b04955ee32c0f98c0f5a51804916a5713f89 (diff) | |
download | server-1172b452e371ba79fe3e5e2f28e23c7f67735771.tar.gz |
Optimize tournament blacklist query.
Only include contacts where both players are in the queue.
Diffstat (limited to 'server.js')
-rw-r--r-- | server.js | 11 |
1 files changed, 10 insertions, 1 deletions
@@ -2764,7 +2764,16 @@ const TM_POOL_LIST_TITLE_FINISHED = SQL(` const TM_POOL_LIST_SEED_ACTIVE = SQL("select * from tm_pool_active_view where seed_id = ?") const TM_POOL_LIST_SEED_FINISHED = SQL("select * from tm_pool_finished_view where seed_id = ?") -const TM_SELECT_QUEUE_BLACKLIST = SQL("select me, you from contacts join tm_queue q on q.user_id=me or q.user_id=you where relation < 0 and seed_id=? and level=?") +const TM_SELECT_QUEUE_BLACKLIST = SQL(` + with qq as ( + select user_id from tm_queue where seed_id=? and level=? + ) + select me, you + from contacts + join qq on qq.user_id = me + where relation < 0 and exists (select 1 from qq where user_id = you) +`) + const TM_SELECT_QUEUE_NAMES = SQL("select user_id, name, level from tm_queue join users using(user_id) where seed_id=? and level=? order by time") const TM_SELECT_QUEUE = SQL("select user_id from tm_queue where seed_id=? and level=? order by time desc").pluck() const TM_DELETE_QUEUE = SQL("delete from tm_queue where user_id=? and seed_id=? and level=?") |