diff options
author | Tor Andersson <tor@ccxvii.net> | 2025-02-12 00:43:24 +0100 |
---|---|---|
committer | Tor Andersson <tor@ccxvii.net> | 2025-02-12 15:08:20 +0100 |
commit | c89a53e7cab4da7cb4513b032beee26195c49ba9 (patch) | |
tree | f5c33339714172a5f9b03bafc992b2d8571ee17b | |
parent | 2f3b4a2f04488308a6ac9d1cf4db299874090e7b (diff) | |
download | server-c89a53e7cab4da7cb4513b032beee26195c49ba9.tar.gz |
Track all game timeouts.
-rw-r--r-- | schema.sql | 15 | ||||
-rw-r--r-- | server.js | 5 |
2 files changed, 12 insertions, 8 deletions
@@ -69,6 +69,15 @@ create table if not exists user_last_seen ( ip text ); +create table if not exists user_timeout ( + user_id integer, + game_id integer, + time datetime default current_timestamp, + primary key (user_id, game_id) +); + +create index if not exists user_timeout_idx on user_timeout(user_id, time); + create table if not exists tokens ( user_id integer primary key, token text, @@ -607,12 +616,6 @@ create table if not exists tm_banned ( time datetime default current_timestamp ); -create table if not exists tm_timeout ( - user_id integer, - game_id integer, - time datetime default current_timestamp -); - create table if not exists tm_queue ( user_id integer, seed_id integer, @@ -2716,14 +2716,16 @@ const SQL_UPDATE_PLAYERS_ADD_TIME = SQL(` const SQL_SELECT_TIME_CONTROL = SQL("select * from time_control_view") +const SQL_INSERT_TIMEOUT = SQL("insert into user_timeout (user_id, game_id) values (?, ?)") + function time_control_ticker() { for (let item of SQL_SELECT_TIME_CONTROL.all()) { if (item.is_opposed) { console.log("TIMED OUT GAME:", item.game_id, item.role) do_timeout(item.game_id, item.role, item.role + " timed out.") + SQL_INSERT_TIMEOUT.run(item.user_id, item.game_id) if (item.is_match) { console.log("BANNED FROM TOURNAMENTS:", item.user_id) - TM_INSERT_TIMEOUT.run(item.user_id, item.game_id) TM_INSERT_BANNED.run(item.user_id) TM_DELETE_QUEUE_ALL.run(item.user_id) } @@ -2748,7 +2750,6 @@ const designs = require("./designs.js") const TM_SELECT_BANNED = SQL("select exists ( select 1 from tm_banned where user_id=? )").pluck() const TM_INSERT_BANNED = SQL("insert or ignore into tm_banned (user_id, time) values (?, datetime())") -const TM_INSERT_TIMEOUT = SQL("insert into tm_timeout (user_id, game_id) values (?, ?)") const TM_DELETE_QUEUE_ALL = SQL("delete from tm_queue where user_id=?") |