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
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "reactmap",
"version": "1.3.3",
"version": "1.3.4",
"description": "React based frontend map.",
"main": "ReactMap.mjs",
"author": "TurtIeSocks <58572875+TurtIeSocks@users.noreply.github.com>",
Expand Down
2 changes: 1 addition & 1 deletion server/src/graphql/resolvers.js
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ module.exports = {
return {
...available,
masterfile: { ...Event.masterfile, invasions: Event.invasions },
filters: Utility.buildDefaultFilters(perms, available),
filters: Utility.buildDefaultFilters(perms, available, Db.models),
}
},
badges: async (_, _args, { req, perms, Db, serverV, clientV }) => {
Expand Down
2 changes: 1 addition & 1 deletion server/src/graphql/scannerTypes.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ module.exports = gql`
type Device {
id: ID
instance_name: String
last_seen: Int
updated: Int
last_lat: Float
last_lon: Float
type: String
Expand Down
16 changes: 16 additions & 0 deletions server/src/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -74,6 +74,21 @@ const server = new ApolloServer({
}
return { message: e.message }
},
formatResponse: (data, context) => {
if (config.devOptions.enabled) {
const endpoint =
context?.operation?.selectionSet?.selections?.[0]?.name?.value
const returned = data?.data?.[endpoint]?.length
console.log(
'[GQL]',
'Endpoint:',
endpoint,
returned ? 'Returned:' : '',
returned || '',
)
}
return null
},
})

server.start().then(() => server.applyMiddleware({ app, path: '/graphql' }))
Expand All @@ -82,6 +97,7 @@ if (config.devOptions.enabled) {
app.use(
logger((tokens, req, res) =>
[
'[EXPRESS]',
tokens.method(req, res),
tokens.url(req, res),
tokens.status(req, res),
Expand Down
4 changes: 2 additions & 2 deletions server/src/models/Device.js
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ module.exports = class Device extends Model {
'settings_device.name AS id',
'settings_area.name AS instance_name',
'mode AS type',
raw('UNIX_TIMESTAMP(lastProtoDateTime)').as('last_seen'),
raw('UNIX_TIMESTAMP(lastProtoDateTime)').as('updated'),
raw('X(currentPos)').as('last_lat'),
raw('Y(currentPos)').as('last_lon'),
raw(true).as('isMad'),
Expand All @@ -28,7 +28,7 @@ module.exports = class Device extends Model {
.join('instance', 'device.instance_name', 'instance.name')
.select(
'uuid AS id',
'last_seen',
'last_seen AS updated',
'last_lat',
'last_lon',
'type',
Expand Down
3 changes: 2 additions & 1 deletion server/src/models/Pokestop.js
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,7 @@ module.exports = class Pokestop extends Model {
multiInvasionMs,
hasRewardAmount,
hasLayerColumn,
hasPowerUp,
},
) {
const {
Expand Down Expand Up @@ -466,7 +467,7 @@ module.exports = class Pokestop extends Model {
})
}
})
} else if (onlyLevels !== 'all' && !isMad) {
} else if (onlyLevels !== 'all' && hasPowerUp) {
query.andWhere('power_up_level', onlyLevels)
}
const results = await query
Expand Down
1 change: 1 addition & 0 deletions server/src/routes/rootRouter.js
Original file line number Diff line number Diff line change
Expand Up @@ -258,6 +258,7 @@ rootRouter.get('/settings', async (req, res) => {
serverSettings.defaultFilters = Utility.buildDefaultFilters(
serverSettings.user.perms,
serverSettings.available,
Db.models,
)

// Backup in case there are Pokemon/Quests/Raids etc that are not in the masterfile
Expand Down
26 changes: 19 additions & 7 deletions server/src/services/DbCheck.js
Original file line number Diff line number Diff line change
Expand Up @@ -79,10 +79,13 @@ module.exports = class DbCheck {
const [isMad, pvpV2] = await schema('pokemon')
.columnInfo()
.then((columns) => ['cp_multiplier' in columns, 'pvp' in columns])
const [hasRewardAmount, hasAltQuests] = await schema('pokestop')
const [hasRewardAmount, hasPowerUp, hasAltQuests] = await schema(
'pokestop',
)
.columnInfo()
.then((columns) => [
'quest_reward_amount' in columns || isMad,
'power_up_level' in columns,
'alternative_quest_type' in columns,
])
const [hasLayerColumn] = isMad
Expand All @@ -109,6 +112,7 @@ module.exports = class DbCheck {
this.models[category][j].isMad = isMad
this.models[category][j].pvpV2 = pvpV2
this.models[category][j].hasRewardAmount = hasRewardAmount
this.models[category][j].hasPowerUp = hasPowerUp
this.models[category][j].hasAltQuests = hasAltQuests
this.models[category][j].hasMultiInvasions = hasMultiInvasions
this.models[category][j].multiInvasionMs = multiInvasionMs
Expand Down Expand Up @@ -159,7 +163,7 @@ module.exports = class DbCheck {
async historicalRarity() {
console.log('[DB] Setting historical rarity stats')
const results = await Promise.all(
this.models.Pokemon.map(async (source) =>
(this.models.Pokemon ?? []).map(async (source) =>
source.isMad
? []
: source.SubModel.query()
Expand Down Expand Up @@ -218,13 +222,21 @@ module.exports = class DbCheck {
static deDupeResults(results) {
if (results.length === 1) return results[0]
if (results.length > 1) {
const returnObj = {}
for (let i = 0; i < results.length; i += 1) {
for (let j = 0; j < results[i].length; j += 1) {
returnObj[results[i][j].id] = results[i][j]
const returnObj = new Map()
const { length } = results
for (let i = 0; i < length; i += 1) {
const { length: subLength } = results[i]
for (let j = 0; j < subLength; j += 1) {
const item = results[i][j]
if (
!returnObj.has(item.id) ||
item.updated > returnObj.get(item.id).updated
) {
returnObj.set(item.id, item)
}
}
}
return Object.values(returnObj)
return returnObj.values()
}
return []
}
Expand Down
5 changes: 0 additions & 5 deletions server/src/services/Utility.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@ const buildDefaultFilters = require('./defaultFilters/buildDefaultFilters')
const primaryUi = require('./ui/primary')
const advMenus = require('./ui/advMenus')
const clientOptions = require('./ui/clientOptions')
const dbSelection = require('./functions/dbSelection')
const webhook = require('./ui/webhook')
const geocoder = require('./geocoder')
const areaPerms = require('./functions/areaPerms')
Expand Down Expand Up @@ -43,10 +42,6 @@ module.exports = class Utility {
return clientOptions(...args)
}

static dbSelection(...args) {
return dbSelection(...args)
}

static webhookUi(...args) {
return webhook(...args)
}
Expand Down
Loading