diff options
-rw-r--r-- | server.js | 14 | ||||
-rw-r--r-- | tools/purge.sql | 4 |
2 files changed, 16 insertions, 2 deletions
@@ -2604,6 +2604,10 @@ function message_link(msg_id) { return SITE_URL + "/message/read/" + msg_id } +function tour_pool_link(pool_id) { + return SITE_URL + "/tm/pool/" + pool_id +} + function send_notification(user, link, message) { if (WEBHOOKS) { let webhook = SQL_SELECT_WEBHOOK_SEND.get(user.user_id) @@ -2638,6 +2642,10 @@ function send_play_notification(user, game_id, message) { send_notification(user, game_play_link(game_id, title_id, user), `${title_name} #${game_id} (${user.role}) - ${message}`) } +function send_tour_notification(user, pool_name, message) { + send_notification(user, tour_pool_link(pool_name), `${pool_name} - ${message}`) +} + function send_chat_activity_notification(game_id, p) { send_play_notification(p, game_id, "Chat activity") } @@ -3534,9 +3542,11 @@ function start_tournament_seed(seed_id, level) { function tm_reap_pools() { // reap pools that are finished (and promote winners) + // reap pools that are finished (and notify players) let ended = TM_SELECT_ENDED_POOLS.all() for (let item of ended) { console.log("TM POOL - END", item.pool_name) + SQL_BEGIN.run() try { TM_UPDATE_POOL_FINISHED.run(item.pool_id) @@ -3550,6 +3560,10 @@ function tm_reap_pools() { if (db.inTransaction) SQL_ROLLBACK.run() } + + let players = TM_SELECT_PLAYERS_IN_POOL.all(item.pool_id) + for (let user of players) + send_tour_notification(user, item.pool_name, "Finished") } } diff --git a/tools/purge.sql b/tools/purge.sql index 8249f01..3e3bfc6 100644 --- a/tools/purge.sql +++ b/tools/purge.sql @@ -1,9 +1,9 @@ -- Prune game snapshot and game state data to save database space. -pragma busy_timeout=10000; - attach database 'db' as live; +pragma live.busy_timeout=10000; + create temporary view prune_snap_list as select distinct game_id |