Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 1 addition & 2 deletions .vscode/extensions.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@
"lokalise.i18n-ally",
"esbenp.prettier-vscode",
"leizongmin.node-module-intellisense",
"eg2.vscode-npm-script",
"2gua.rainbow-brackets"
"eg2.vscode-npm-script"
]
}
10 changes: 5 additions & 5 deletions server/src/models/Gym.js
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ module.exports = class Gym extends Model {
return 'gym'
}

static async getAll(perms, args, { isMad }, userId) {
static async getAll(perms, args, { isMad, availableSlotsCol }, userId) {
const { gyms: gymPerms, raids: raidPerms, areaRestrictions, gymBadges } = perms
const {
onlyAllGyms, onlyRaids, onlyExEligible, onlyInBattle, onlyArEligible, onlyRaidTier, onlyGymBadges, onlyBadge, ts,
Expand Down Expand Up @@ -167,7 +167,7 @@ module.exports = class Gym extends Model {
if (teamSlots.length) {
gym.orWhere(gymSlot => {
gymSlot.where('team_id', team)
.whereIn(isMad ? 'slots_available' : 'availble_slots', teamSlots)
.whereIn(isMad ? 'slots_available' : availableSlotsCol, teamSlots)
})
}
})
Expand Down Expand Up @@ -252,7 +252,7 @@ module.exports = class Gym extends Model {
return secondaryFilter(await query.limit(queryLimits.gyms))
}

static async getAvailable({ isMad }) {
static async getAvailable({ isMad, availableSlotsCol }) {
const ts = Math.floor((new Date()).getTime() / 1000)
const results = await this.query()
.select([
Expand All @@ -272,11 +272,11 @@ module.exports = class Gym extends Model {
const teamResults = await this.query()
.select([
'team_id AS team',
isMad ? 'slots_available AS slots' : 'availble_slots AS slots',
isMad ? 'slots_available AS slots' : `${availableSlotsCol} AS slots`,
])
.groupBy([
'team_id',
isMad ? 'slots_available' : 'availble_slots',
isMad ? 'slots_available' : availableSlotsCol,
])
.then((r) => {
const unique = new Set()
Expand Down
12 changes: 10 additions & 2 deletions server/src/services/DbCheck.js
Original file line number Diff line number Diff line change
Expand Up @@ -49,8 +49,11 @@ module.exports = class DbCheck {
console.log(`[DB] Determining database types for ${this.connections.length} connection${this.connections.length > 1 ? 's' : ''}`)
await Promise.all(this.connections.map(async (schema, i) => {
try {
const isMad = await schema('trs_quest').columnInfo().then(col => Object.keys(col).length > 0)
const pvpV2 = await schema('pokemon').columnInfo().then(col => 'pvp' in col)
const [isMad, pvpV2] = await schema('pokemon').columnInfo()
.then(columns => [
'cp_multiplier' in columns,
'pvp' in columns,
])
const [hasRewardAmount, hasAltQuests] = await schema('pokestop').columnInfo()
.then(columns => ([
('quest_reward_amount' in columns || isMad),
Expand All @@ -61,6 +64,10 @@ module.exports = class DbCheck {
'character' in columns,
'expiration_ms' in columns,
]))
const [availableSlotsCol] = await schema('gym').columnInfo()
.then(columns => ([
'availble_slots' in columns ? 'availble_slots' : 'available_slots',
]))
Object.entries(this.models).forEach(([category, sources]) => {
sources.forEach((source, j) => {
if (source.connection === i) {
Expand All @@ -70,6 +77,7 @@ module.exports = class DbCheck {
this.models[category][j].hasAltQuests = hasAltQuests
this.models[category][j].hasMultiInvasions = hasMultiInvasions
this.models[category][j].multiInvasionMs = multiInvasionMs
this.models[category][j].availableSlotsCol = availableSlotsCol
}
})
})
Expand Down