From c8fa571f32b10c083fab07f28d2ef55895ef40af Mon Sep 17 00:00:00 2001 From: Chocobozzz Date: Fri, 22 Jul 2022 15:22:21 +0200 Subject: Clearer live session Get the save replay setting when the session started to prevent inconsistent behaviour when the setting changed before the session was processed by the live ending job Display more information about the potential session replay in live modal information --- server/initializers/constants.ts | 2 +- .../migrations/0720-session-ending-processed.ts | 56 ++++++++++++++++++++++ 2 files changed, 57 insertions(+), 1 deletion(-) create mode 100644 server/initializers/migrations/0720-session-ending-processed.ts (limited to 'server/initializers') diff --git a/server/initializers/constants.ts b/server/initializers/constants.ts index 8cb4d5f4a..e3f7ceb4a 100644 --- a/server/initializers/constants.ts +++ b/server/initializers/constants.ts @@ -24,7 +24,7 @@ import { CONFIG, registerConfigChangedHandler } from './config' // --------------------------------------------------------------------------- -const LAST_MIGRATION_VERSION = 715 +const LAST_MIGRATION_VERSION = 720 // --------------------------------------------------------------------------- diff --git a/server/initializers/migrations/0720-session-ending-processed.ts b/server/initializers/migrations/0720-session-ending-processed.ts new file mode 100644 index 000000000..74ffb39a0 --- /dev/null +++ b/server/initializers/migrations/0720-session-ending-processed.ts @@ -0,0 +1,56 @@ +import * as Sequelize from 'sequelize' + +async function up (utils: { + transaction: Sequelize.Transaction + queryInterface: Sequelize.QueryInterface + sequelize: Sequelize.Sequelize + db: any +}): Promise { + const { transaction } = utils + + { + const data = { + type: Sequelize.BOOLEAN, + defaultValue: null, + allowNull: true + } + await utils.queryInterface.addColumn('videoLiveSession', 'endingProcessed', data, { transaction }) + await utils.queryInterface.addColumn('videoLiveSession', 'saveReplay', data, { transaction }) + } + + { + const query = `UPDATE "videoLiveSession" SET "saveReplay" = ( + SELECT "videoLive"."saveReplay" FROM "videoLive" WHERE "videoLive"."videoId" = "videoLiveSession"."liveVideoId" + ) WHERE "videoLiveSession"."liveVideoId" IS NOT NULL` + await utils.sequelize.query(query, { transaction }) + } + + { + const query = `UPDATE "videoLiveSession" SET "saveReplay" = FALSE WHERE "saveReplay" IS NULL` + await utils.sequelize.query(query, { transaction }) + } + + { + const query = `UPDATE "videoLiveSession" SET "endingProcessed" = TRUE` + await utils.sequelize.query(query, { transaction }) + } + + { + const data = { + type: Sequelize.BOOLEAN, + defaultValue: null, + allowNull: false + } + await utils.queryInterface.changeColumn('videoLiveSession', 'endingProcessed', data, { transaction }) + await utils.queryInterface.changeColumn('videoLiveSession', 'saveReplay', data, { transaction }) + } +} + +function down (options) { + throw new Error('Not implemented.') +} + +export { + up, + down +} -- cgit v1.2.3