From 9b61655063e962f954b43f417ffef058d17e2e00 Mon Sep 17 00:00:00 2001 From: TurtIeSocks <58572875+TurtIeSocks@users.noreply.github.com> Date: Wed, 3 Aug 2022 08:51:16 -0400 Subject: [PATCH] Support MAD Layer Column - Checks to see whether the new `layer` column exists - Selects it as `with_ar` for easy compatibility with existing code - Backwards compatible --- server/src/models/Pokestop.js | 4 ++++ server/src/services/DbCheck.js | 6 ++++++ 2 files changed, 10 insertions(+) diff --git a/server/src/models/Pokestop.js b/server/src/models/Pokestop.js index 3dc6a02c8..c929a9002 100644 --- a/server/src/models/Pokestop.js +++ b/server/src/models/Pokestop.js @@ -59,6 +59,7 @@ module.exports = class Pokestop extends Model { hasMultiInvasions, multiInvasionMs, hasRewardAmount, + hasLayerColumn, }, ) { const { @@ -110,6 +111,9 @@ module.exports = class Pokestop extends Model { 'incident_expire_timestamp', ), ]) + if (hasLayerColumn) { + query.select('layer AS with_ar') + } if (hideOldPokestops) { query.whereRaw( `UNIX_TIMESTAMP(last_updated) > ${ diff --git a/server/src/services/DbCheck.js b/server/src/services/DbCheck.js index 58194754b..122627991 100644 --- a/server/src/services/DbCheck.js +++ b/server/src/services/DbCheck.js @@ -85,6 +85,11 @@ module.exports = class DbCheck { 'quest_reward_amount' in columns || isMad, 'alternative_quest_type' in columns, ]) + const [hasLayerColumn] = isMad + ? await schema('trs_quest') + .columnInfo() + .then((columns) => ['layer' in columns]) + : [false] const [hasMultiInvasions, multiInvasionMs] = await schema('incident') .columnInfo() .then((columns) => [ @@ -108,6 +113,7 @@ module.exports = class DbCheck { this.models[category][j].hasMultiInvasions = hasMultiInvasions this.models[category][j].multiInvasionMs = multiInvasionMs this.models[category][j].availableSlotsCol = availableSlotsCol + this.models[category][j].hasLayerColumn = hasLayerColumn } }) })