From 3f2fc2efc2ef14cff27c3582de8384fe20ff86be Mon Sep 17 00:00:00 2001
From: TurtIeSocks <58572875+TurtIeSocks@users.noreply.github.com>
Date: Fri, 12 Aug 2022 18:45:55 -0400
Subject: [PATCH 01/23] Experimental Poke Endpoint
Testing stuff :eyes:
---
package.json | 4 +-
server/src/models/Pokemon.js | 28 ++++++++--
server/src/services/DbCheck.js | 13 ++++-
yarn.lock | 93 ++++++++++++++++++----------------
4 files changed, 86 insertions(+), 52 deletions(-)
diff --git a/package.json b/package.json
index db33f3d0c..3106375e0 100644
--- a/package.json
+++ b/package.json
@@ -84,7 +84,7 @@
"i18next-browser-languagedetector": "^6.1.4",
"i18next-fs-backend": "^1.1.4",
"i18next-http-backend": "^1.4.0",
- "knex": "^0.95.11",
+ "knex": "^2.2.0",
"leaflet": "^1.7.1",
"leaflet.locatecontrol": "^0.73.0",
"leaflet.markercluster": "^1.4.1",
@@ -95,7 +95,7 @@
"node-fetch": "2",
"node-geocoder": "^4.0.0",
"nodes2ts": "^2.0.0",
- "objection": "^3.0.0",
+ "objection": "^3.0.1",
"ohbem": "^1.4.1",
"passport": "^0.4.1",
"passport-discord": "https://github.com/tonestrike/passport-discord.git",
diff --git a/server/src/models/Pokemon.js b/server/src/models/Pokemon.js
index b96c2cf49..9e301f66d 100644
--- a/server/src/models/Pokemon.js
+++ b/server/src/models/Pokemon.js
@@ -11,6 +11,7 @@ const {
} = require('../services/config')
const getAreaSql = require('../services/functions/getAreaSql')
const { Pvp } = require('../services/initialization')
+const fetchJson = require('../services/api/fetchJson')
const levelCalc =
'IFNULL(IF(cp_multiplier < 0.734, ROUND(58.35178527 * cp_multiplier * cp_multiplier - 2.838007664 * cp_multiplier + 0.8539209906), ROUND(171.0112688 * cp_multiplier - 95.20425243)), NULL)'
@@ -69,7 +70,7 @@ module.exports = class Pokemon extends Model {
return 'pokemon'
}
- static async getAll(perms, args, { isMad, pvpV2 }) {
+ static async getAll(perms, args, { isMad, pvpV2, mem }) {
const { iv: ivs, pvp, areaRestrictions } = perms
const {
onlyStandard,
@@ -262,7 +263,16 @@ module.exports = class Pokemon extends Model {
return []
}
- const results = await query.limit(queryLimits.pokemon)
+ const results = mem
+ ? await fetchJson(mem, {
+ method: 'POST',
+ headers: {
+ Accept: 'application/json',
+ 'Content-Type': 'application/json',
+ },
+ body: query.toKnexQuery().toString(),
+ })
+ : await query.limit(queryLimits.pokemon)
const finalResults = []
const pvpResults = []
const listOfIds = []
@@ -344,7 +354,16 @@ module.exports = class Pokemon extends Model {
return []
}
pvpResults.push(
- ...(await pvpQuery.limit(queryLimits.pokemonPvp - results.length)),
+ ...(mem
+ ? await fetchJson(mem, {
+ method: 'POST',
+ headers: {
+ Accept: 'application/json',
+ 'Content-Type': 'application/json',
+ },
+ body: pvpQuery.toKnexQuery().toString(),
+ })
+ : await pvpQuery.limit(queryLimits.pokemonPvp - results.length)),
)
}
@@ -414,7 +433,8 @@ module.exports = class Pokemon extends Model {
return legacyFilter(results, args, perms, ts)
}
- static async getAvailable({ isMad }) {
+ static async getAvailable({ isMad, mem }) {
+ if (mem) return []
const ts = Math.floor(new Date().getTime() / 1000)
const availableQuery = this.query()
.select(['pokemon_id', 'form'])
diff --git a/server/src/services/DbCheck.js b/server/src/services/DbCheck.js
index 122627991..c621ebce7 100644
--- a/server/src/services/DbCheck.js
+++ b/server/src/services/DbCheck.js
@@ -18,6 +18,7 @@ module.exports = class DbCheck {
this.rarityPercents = rarityPercents
this.models = {}
this.questConditions = {}
+ this.memEndpoints = {}
this.rarity = new Map()
this.historical = new Map()
this.connections = dbSettings.schemas
@@ -32,6 +33,9 @@ module.exports = class DbCheck {
}
this.models[capital].push({ connection: i })
})
+ if (schema.endpoint) {
+ this.memEndpoints[i] = schema.endpoint
+ }
return knex({
client: 'mysql2',
connection: {
@@ -76,9 +80,13 @@ module.exports = class DbCheck {
await Promise.all(
this.connections.map(async (schema, i) => {
try {
- const [isMad, pvpV2] = await schema('pokemon')
+ const [isMad, pvpV2, mem] = await schema('pokemon')
.columnInfo()
- .then((columns) => ['cp_multiplier' in columns, 'pvp' in columns])
+ .then((columns) => [
+ 'cp_multiplier' in columns,
+ 'pvp' in columns,
+ Object.keys(columns).length ? false : this.memEndpoints[i],
+ ])
const [hasRewardAmount, hasAltQuests] = await schema('pokestop')
.columnInfo()
.then((columns) => [
@@ -108,6 +116,7 @@ module.exports = class DbCheck {
if (source.connection === i) {
this.models[category][j].isMad = isMad
this.models[category][j].pvpV2 = pvpV2
+ this.models[category][j].mem = mem
this.models[category][j].hasRewardAmount = hasRewardAmount
this.models[category][j].hasAltQuests = hasAltQuests
this.models[category][j].hasMultiInvasions = hasMultiInvasions
diff --git a/yarn.lock b/yarn.lock
index a637bc70b..fb8ba1274 100644
--- a/yarn.lock
+++ b/yarn.lock
@@ -831,9 +831,9 @@ ajv@^6.10.0, ajv@^6.12.4:
uri-js "^4.2.2"
ajv@^8.6.2:
- version "8.8.2"
- resolved "https://registry.yarnpkg.com/ajv/-/ajv-8.8.2.tgz#01b4fef2007a28bf75f0b7fc009f62679de4abbb"
- integrity sha512-x9VuX+R/jcFj1DHo/fCp99esgGDWiHENrKxaCENuCxpoMCmAt/COCGVDwA7kleEpEzJjDnvh3yGoOuLu0Dtllw==
+ version "8.11.0"
+ resolved "https://registry.yarnpkg.com/ajv/-/ajv-8.11.0.tgz#977e91dd96ca669f54a11e23e378e33b884a565f"
+ integrity sha512-wGgprdCvMalC0BztXvitD2hC04YffAvtsUn93JbGXYLAtCUO4xd17mCCZQxUOItiBwZvJScWo8NIvQMQ71rdpg==
dependencies:
fast-deep-equal "^3.1.1"
json-schema-traverse "^1.0.0"
@@ -1232,10 +1232,10 @@ color-support@^1.1.2:
resolved "https://registry.yarnpkg.com/color-support/-/color-support-1.1.3.tgz#93834379a1cc9a0c61f82f52f0d04322251bd5a2"
integrity sha512-qiBjkpbMLO/HL68y+lh4q0/O1MZFj2RX6X/KmMa3+gJD3z+WwI1ZzDHysvqHGS3mP6mznPckpXmw1nI9cJjyRg==
-colorette@2.0.16:
- version "2.0.16"
- resolved "https://registry.yarnpkg.com/colorette/-/colorette-2.0.16.tgz#713b9af84fdb000139f04546bd4a93f62a5085da"
- integrity sha512-hUewv7oMjCp+wkBv5Rm0v87eJhq4woh5rSR+42YSQJKecCqgIqNkZ6lAlQms/BwHPJA5NKMRlpxPRv0n8HQW6g==
+colorette@2.0.19:
+ version "2.0.19"
+ resolved "https://registry.yarnpkg.com/colorette/-/colorette-2.0.19.tgz#cdf044f47ad41a0f4b56b3a0d5b4e6e1a2d5a798"
+ integrity sha512-3tlv/dIP7FWvj3BsbHrGLJ6l/oKh1O3TcgBqMn+yyCagOxc23fyzDS6HypQbgxWbkpDnf52p1LuR4eWDQ/K9WQ==
combined-stream@^1.0.8:
version "1.0.8"
@@ -1249,10 +1249,10 @@ commander@^2.20.3:
resolved "https://registry.yarnpkg.com/commander/-/commander-2.20.3.tgz#fd485e84c03eb4881c20722ba48035e8531aeb33"
integrity sha512-GpVkmM8vF2vQUkj2LvZmD35JxeJOLCwJ9cUkugyk2nuhbv3+mJvpLYYt+0+USMxE+oj+ey/lJEnhZw75x/OMcQ==
-commander@^7.1.0:
- version "7.2.0"
- resolved "https://registry.yarnpkg.com/commander/-/commander-7.2.0.tgz#a36cb57d0b501ce108e4d20559a150a391d97ab7"
- integrity sha512-QrWXB+ZQSVPmIWIhtEO9H+gwHaMGYiF5ChvoJ+K9ZGHG/sVsa6yiesAD1GC/x46sET00Xlwo1u49RVVVzvcSkw==
+commander@^9.1.0:
+ version "9.4.0"
+ resolved "https://registry.yarnpkg.com/commander/-/commander-9.4.0.tgz#bc4a40918fefe52e22450c111ecd6b7acce6f11c"
+ integrity sha512-sRPT+umqkz90UA8M1yqYfnHlZA7fF6nSphDtxeywPZ49ysjxDQybzk13CL+mXekDRG92skbcqCLVovuCusNmFw==
compressible@~2.0.16:
version "2.0.18"
@@ -1423,7 +1423,7 @@ debug@2.6.9, debug@^2.6.9:
dependencies:
ms "2.0.0"
-debug@4, debug@4.3.2:
+debug@4:
version "4.3.2"
resolved "https://registry.yarnpkg.com/debug/-/debug-4.3.2.tgz#f0a49c18ac8779e31d4a0c6029dfb76873c7428b"
integrity sha512-mOp8wKcvj7XxC78zLgw/ZA+6TSgkoE2C/ienthhRD298T7UNwAg9diBpLRxC0mOezLl4B0xV7M0cCO6P/O0Xhw==
@@ -1437,6 +1437,13 @@ debug@4.3.1:
dependencies:
ms "2.1.2"
+debug@4.3.4:
+ version "4.3.4"
+ resolved "https://registry.yarnpkg.com/debug/-/debug-4.3.4.tgz#1319f6579357f2338d3337d2cdd4914bb5dcc865"
+ integrity sha512-PRWFHuSU3eDtQJPvnNY7Jcket1j0t5OuOsFzPPzsekD52Zl8qUfFIPEiswXqIvHWGVHOgX+7G/vCNNhehwxfkQ==
+ dependencies:
+ ms "2.1.2"
+
debug@^3.2.7:
version "3.2.7"
resolved "https://registry.yarnpkg.com/debug/-/debug-3.2.7.tgz#72580b7e9145fb39b6676f9c5e5fb100b934179a"
@@ -2268,6 +2275,11 @@ get-intrinsic@^1.0.2, get-intrinsic@^1.1.0, get-intrinsic@^1.1.1:
has "^1.0.3"
has-symbols "^1.0.1"
+get-package-type@^0.1.0:
+ version "0.1.0"
+ resolved "https://registry.yarnpkg.com/get-package-type/-/get-package-type-0.1.0.tgz#8de2d803cff44df3bc6c456e6668b36c3926e11a"
+ integrity sha512-pjzuKtY64GYfWizNAJ0fr9VqttZkNiK2iS430LtIHzjBEr6bX8Am2zm4sW4Ro5wjWW5cAlRL1qAMTcXbjNAO2Q==
+
get-symbol-description@^1.0.0:
version "1.0.0"
resolved "https://registry.yarnpkg.com/get-symbol-description/-/get-symbol-description-1.0.0.tgz#7fdb81c900101fbd564dd5f1a30af5aadc1e58d6"
@@ -2276,10 +2288,10 @@ get-symbol-description@^1.0.0:
call-bind "^1.0.2"
get-intrinsic "^1.1.1"
-getopts@2.2.5:
- version "2.2.5"
- resolved "https://registry.yarnpkg.com/getopts/-/getopts-2.2.5.tgz#67a0fe471cacb9c687d817cab6450b96dde8313b"
- integrity sha512-9jb7AW5p3in+IiJWhQiZmmwkpLaR/ccTWdWQCtZM66HJcHHLegowh4q4tSD7gouUyeNvFWRavfK9GXosQHDpFA==
+getopts@2.3.0:
+ version "2.3.0"
+ resolved "https://registry.yarnpkg.com/getopts/-/getopts-2.3.0.tgz#71e5593284807e03e2427449d4f6712a268666f4"
+ integrity sha512-5eDf9fuSXwxBL6q5HX+dhDj+dslFGWzU5thZ9kNKUkcPtaPdatmUFKwHFrLb/uf/WpA4BHET+AX3Scl56cAjpA==
glob-parent@^6.0.1:
version "6.0.2"
@@ -2875,23 +2887,24 @@ jss@10.6.0, jss@^10.5.1:
array-includes "^3.1.3"
object.assign "^4.1.2"
-knex@^0.95.11:
- version "0.95.15"
- resolved "https://registry.yarnpkg.com/knex/-/knex-0.95.15.tgz#39d7e7110a6e2ad7de5d673d2dea94143015e0e7"
- integrity sha512-Loq6WgHaWlmL2bfZGWPsy4l8xw4pOE+tmLGkPG0auBppxpI0UcK+GYCycJcqz9W54f2LiGewkCVLBm3Wq4ur/w==
+knex@^2.2.0:
+ version "2.2.0"
+ resolved "https://registry.yarnpkg.com/knex/-/knex-2.2.0.tgz#86a3176924d37303b3f9ff7f70087418c263ce7a"
+ integrity sha512-yhm1Qe9Ok0TeXBq3nNHqZYJPrQ4Iw2tq9k/HxjrZ/EWec2ifOjJlkNHr26v8cQrWtk5iG3iwfUazTIWy+VKG5g==
dependencies:
- colorette "2.0.16"
- commander "^7.1.0"
- debug "4.3.2"
+ colorette "2.0.19"
+ commander "^9.1.0"
+ debug "4.3.4"
escalade "^3.1.1"
esm "^3.2.25"
- getopts "2.2.5"
+ get-package-type "^0.1.0"
+ getopts "2.3.0"
interpret "^2.2.0"
lodash "^4.17.21"
pg-connection-string "2.5.0"
- rechoir "0.7.0"
+ rechoir "^0.8.0"
resolve-from "^5.0.0"
- tarn "^3.0.1"
+ tarn "^3.0.2"
tildify "2.0.0"
language-subtag-registry@~0.3.2:
@@ -3358,10 +3371,10 @@ object.values@^1.1.5:
define-properties "^1.1.3"
es-abstract "^1.19.1"
-objection@^3.0.0:
- version "3.0.0"
- resolved "https://registry.yarnpkg.com/objection/-/objection-3.0.0.tgz#213e76db48c774935813d184adc4a2cc1461c773"
- integrity sha512-dIQZKlWQ24SWQSLkd8t/h+MUTr3P3ziVT9rztRtZT/tt/SGFyj4Zgvp+TN/SXfxgVMSfBLQxeLlioe0n64suMg==
+objection@^3.0.1:
+ version "3.0.1"
+ resolved "https://registry.yarnpkg.com/objection/-/objection-3.0.1.tgz#f67dc698187d10524e5d1b5d37a54e5bba49a42a"
+ integrity sha512-rqNnyQE+C55UHjdpTOJEKQHJGZ/BGtBBtgxdUpKG4DQXRUmqxfmgS/MhPWxB9Pw0mLSVLEltr6soD4c0Sddy0Q==
dependencies:
ajv "^8.6.2"
db-errors "^0.2.3"
@@ -3825,12 +3838,12 @@ readdirp@~3.6.0:
dependencies:
picomatch "^2.2.1"
-rechoir@0.7.0:
- version "0.7.0"
- resolved "https://registry.yarnpkg.com/rechoir/-/rechoir-0.7.0.tgz#32650fd52c21ab252aa5d65b19310441c7e03aca"
- integrity sha512-ADsDEH2bvbjltXEP+hTIAmeFekTFK0V2BTxMkok6qILyAJEXV0AFfoWcAq4yfll5VdIMd/RVXq0lR+wQi5ZU3Q==
+rechoir@^0.8.0:
+ version "0.8.0"
+ resolved "https://registry.yarnpkg.com/rechoir/-/rechoir-0.8.0.tgz#49f866e0d32146142da3ad8f0eff352b3215ff22"
+ integrity sha512-/vxpCXddiX8NGfGO/mTafwjq4aFa/71pvamip0++IQk3zG8cbCj0fifNPrjjF1XMXUne91jL9OoxmdykoEtifQ==
dependencies:
- resolve "^1.9.0"
+ resolve "^1.20.0"
regenerator-runtime@^0.13.4:
version "0.13.7"
@@ -3883,14 +3896,6 @@ resolve@^1.20.0:
path-parse "^1.0.7"
supports-preserve-symlinks-flag "^1.0.0"
-resolve@^1.9.0:
- version "1.20.0"
- resolved "https://registry.yarnpkg.com/resolve/-/resolve-1.20.0.tgz#629a013fb3f70755d6f0b7935cc1c2c5378b1975"
- integrity sha512-wENBPt4ySzg4ybFQW2TT1zMQucPK95HSh/nq2CFTZVOGut2+pQvSsgtda4d26YrYcr067wjbmzOG8byDPBX63A==
- dependencies:
- is-core-module "^2.2.0"
- path-parse "^1.0.6"
-
resolve@^2.0.0-next.3:
version "2.0.0-next.3"
resolved "https://registry.yarnpkg.com/resolve/-/resolve-2.0.0-next.3.tgz#d41016293d4a8586a39ca5d9b5f15cbea1f55e46"
@@ -4215,7 +4220,7 @@ tar@^6.1.11:
mkdirp "^1.0.3"
yallist "^4.0.0"
-tarn@^3.0.1:
+tarn@^3.0.2:
version "3.0.2"
resolved "https://registry.yarnpkg.com/tarn/-/tarn-3.0.2.tgz#73b6140fbb881b71559c4f8bfde3d9a4b3d27693"
integrity sha512-51LAVKUSZSVfI05vjPESNc5vwqqZpbXCsU+/+wxlOrUjk2SnFTt97v9ZgQrD4YmxYW1Px6w2KjaDitCfkvgxMQ==
From 0c9a8616f4ce75e118e13d2094b958c8dd069beb Mon Sep 17 00:00:00 2001
From: TurtIeSocks <58572875+TurtIeSocks@users.noreply.github.com>
Date: Fri, 12 Aug 2022 18:48:33 -0400
Subject: [PATCH 02/23] Linting
---
src/components/markers/pokemon.jsx | 2 +-
src/components/tiles/Pokemon.jsx | 6 +++++-
2 files changed, 6 insertions(+), 2 deletions(-)
diff --git a/src/components/markers/pokemon.jsx b/src/components/markers/pokemon.jsx
index d1a111111..2fe292fdd 100644
--- a/src/components/markers/pokemon.jsx
+++ b/src/components/markers/pokemon.jsx
@@ -53,7 +53,7 @@ export const fancyMarker = (
{pkmn.seen_type === 'nearby_cell' && (
Date: Sat, 13 Aug 2022 11:00:25 -0400
Subject: [PATCH 03/23] minor bug fixes
---
server/src/models/Pokemon.js | 2 +-
server/src/services/DbCheck.js | 2 +-
2 files changed, 2 insertions(+), 2 deletions(-)
diff --git a/server/src/models/Pokemon.js b/server/src/models/Pokemon.js
index 9e301f66d..2b03ca8ba 100644
--- a/server/src/models/Pokemon.js
+++ b/server/src/models/Pokemon.js
@@ -434,7 +434,7 @@ module.exports = class Pokemon extends Model {
}
static async getAvailable({ isMad, mem }) {
- if (mem) return []
+ if (mem) return [{ available: [], rarity: [] }]
const ts = Math.floor(new Date().getTime() / 1000)
const availableQuery = this.query()
.select(['pokemon_id', 'form'])
diff --git a/server/src/services/DbCheck.js b/server/src/services/DbCheck.js
index c621ebce7..eb01bd39b 100644
--- a/server/src/services/DbCheck.js
+++ b/server/src/services/DbCheck.js
@@ -169,7 +169,7 @@ module.exports = class DbCheck {
console.log('[DB] Setting historical rarity stats')
const results = await Promise.all(
this.models.Pokemon.map(async (source) =>
- source.isMad
+ source.isMad || source.mem
? []
: source.SubModel.query()
.select('pokemon_id', raw('SUM(count) as total'))
From 5bc59977119b2118610608f9771de0549dc33348 Mon Sep 17 00:00:00 2001
From: TurtIeSocks <58572875+TurtIeSocks@users.noreply.github.com>
Date: Sat, 13 Aug 2022 13:17:54 -0400
Subject: [PATCH 04/23] force bools
---
server/src/models/Pokemon.js | 4 ++++
server/src/services/legacyFilter.js | 4 ++--
2 files changed, 6 insertions(+), 2 deletions(-)
diff --git a/server/src/models/Pokemon.js b/server/src/models/Pokemon.js
index 2b03ca8ba..a25c2368a 100644
--- a/server/src/models/Pokemon.js
+++ b/server/src/models/Pokemon.js
@@ -303,6 +303,8 @@ module.exports = class Pokemon extends Model {
pvpResults.push(pkmn)
}
if (noPvp && globalCheck(pkmn)) {
+ pkmn.changed = !!pkmn.changed
+ pkmn.expire_timestamp_verified = !!pkmn.expire_timestamp_verified
finalResults.push(pkmn)
}
})
@@ -393,6 +395,8 @@ module.exports = class Pokemon extends Model {
(Object.keys(pkmn.cleanPvp).length || !pkmn.pvpCheck) &&
globalCheck(pkmn)
) {
+ pkmn.changed = !!pkmn.changed
+ pkmn.expire_timestamp_verified = !!pkmn.expire_timestamp_verified
finalResults.push(pkmn)
}
})
diff --git a/server/src/services/legacyFilter.js b/server/src/services/legacyFilter.js
index 05b6e7ca4..104885295 100644
--- a/server/src/services/legacyFilter.js
+++ b/server/src/services/legacyFilter.js
@@ -359,9 +359,9 @@ const getLegacy = (results, args, perms, ts) => {
filtered.pokestop_id = result.pokestop_id
filtered.first_seen_timestamp = result.first_seen_timestamp
filtered.updated = result.updated
- filtered.changed = result.changed
+ filtered.changed = !!result.changed
filtered.cellId = result.cell_id
- filtered.expire_timestamp_verified = result.expire_timestamp_verified
+ filtered.expire_timestamp_verified = !!result.expire_timestamp_verified
filtered.display_pokemon_id = result.display_pokemon_id
if (perms.iv) {
filtered.move_1 = result.move_1
From 40f61f1f4f9f947234677928aae9c992a7bc1350 Mon Sep 17 00:00:00 2001
From: TurtIeSocks <58572875+TurtIeSocks@users.noreply.github.com>
Date: Sat, 13 Aug 2022 13:23:46 -0400
Subject: [PATCH 05/23] consistent typing
---
server/src/models/Pokemon.js | 4 ++--
server/src/services/DbCheck.js | 2 +-
2 files changed, 3 insertions(+), 3 deletions(-)
diff --git a/server/src/models/Pokemon.js b/server/src/models/Pokemon.js
index a25c2368a..b9be92d14 100644
--- a/server/src/models/Pokemon.js
+++ b/server/src/models/Pokemon.js
@@ -304,7 +304,7 @@ module.exports = class Pokemon extends Model {
}
if (noPvp && globalCheck(pkmn)) {
pkmn.changed = !!pkmn.changed
- pkmn.expire_timestamp_verified = !!pkmn.expire_timestamp_verified
+ pkmn.expire_timestamp_verified = !!pkmn.expire_timestamp_verified
finalResults.push(pkmn)
}
})
@@ -396,7 +396,7 @@ module.exports = class Pokemon extends Model {
globalCheck(pkmn)
) {
pkmn.changed = !!pkmn.changed
- pkmn.expire_timestamp_verified = !!pkmn.expire_timestamp_verified
+ pkmn.expire_timestamp_verified = !!pkmn.expire_timestamp_verified
finalResults.push(pkmn)
}
})
diff --git a/server/src/services/DbCheck.js b/server/src/services/DbCheck.js
index eb01bd39b..bad3c85e1 100644
--- a/server/src/services/DbCheck.js
+++ b/server/src/services/DbCheck.js
@@ -85,7 +85,7 @@ module.exports = class DbCheck {
.then((columns) => [
'cp_multiplier' in columns,
'pvp' in columns,
- Object.keys(columns).length ? false : this.memEndpoints[i],
+ Object.keys(columns).length ? '' : this.memEndpoints[i],
])
const [hasRewardAmount, hasAltQuests] = await schema('pokestop')
.columnInfo()
From e5a0009f4da1801062dab7f82ae990195eb1a432 Mon Sep 17 00:00:00 2001
From: TurtIeSocks <58572875+TurtIeSocks@users.noreply.github.com>
Date: Sat, 13 Aug 2022 13:50:21 -0400
Subject: [PATCH 06/23] abstract out the fn
---
server/src/models/Pokemon.js | 107 +++++++++++++++++++----------------
1 file changed, 57 insertions(+), 50 deletions(-)
diff --git a/server/src/models/Pokemon.js b/server/src/models/Pokemon.js
index b9be92d14..18f47ecf6 100644
--- a/server/src/models/Pokemon.js
+++ b/server/src/models/Pokemon.js
@@ -263,16 +263,7 @@ module.exports = class Pokemon extends Model {
return []
}
- const results = mem
- ? await fetchJson(mem, {
- method: 'POST',
- headers: {
- Accept: 'application/json',
- 'Content-Type': 'application/json',
- },
- body: query.toKnexQuery().toString(),
- })
- : await query.limit(queryLimits.pokemon)
+ const results = await this.evalQuery(mem, query.limit(queryLimits.pokemon))
const finalResults = []
const pvpResults = []
const listOfIds = []
@@ -356,16 +347,10 @@ module.exports = class Pokemon extends Model {
return []
}
pvpResults.push(
- ...(mem
- ? await fetchJson(mem, {
- method: 'POST',
- headers: {
- Accept: 'application/json',
- 'Content-Type': 'application/json',
- },
- body: pvpQuery.toKnexQuery().toString(),
- })
- : await pvpQuery.limit(queryLimits.pokemonPvp - results.length)),
+ ...(await this.evalQuery(
+ mem,
+ pvpQuery.limit(queryLimits.pokemonPvp - results.length),
+ )),
)
}
@@ -403,8 +388,21 @@ module.exports = class Pokemon extends Model {
return finalResults
}
- static async getLegacy(perms, args, { isMad }) {
- const ts = Math.floor(new Date().getTime() / 1000)
+ static async evalQuery(mem, query) {
+ return mem
+ ? fetchJson(mem, {
+ method: 'POST',
+ headers: {
+ Accept: 'application/json',
+ 'Content-Type': 'application/json',
+ },
+ body: query.toKnexQuery().toString(),
+ })
+ : query
+ }
+
+ static async getLegacy(perms, args, { mem, isMad }) {
+ const ts = Math.floor(Date.now() / 1000)
const query = this.query()
.where(
isMad ? 'disappear_time' : 'expire_timestamp',
@@ -433,31 +431,37 @@ module.exports = class Pokemon extends Model {
) {
return []
}
- const results = await query
+ const results = await this.evalQuery(mem, query)
return legacyFilter(results, args, perms, ts)
}
static async getAvailable({ isMad, mem }) {
if (mem) return [{ available: [], rarity: [] }]
- const ts = Math.floor(new Date().getTime() / 1000)
- const availableQuery = this.query()
- .select(['pokemon_id', 'form'])
- .where(
- isMad ? 'disappear_time' : 'expire_timestamp',
- '>=',
- isMad ? this.knex().fn.now() : ts,
- )
- .groupBy('pokemon_id', 'form')
- .orderBy('pokemon_id', 'form')
- const rarityQuery = this.query()
- .select(['pokemon_id AS id', 'form as formId'])
- .count('pokemon_id AS count')
- .groupBy('pokemon_id', 'form')
- .where(
- isMad ? 'disappear_time' : 'expire_timestamp',
- '>=',
- isMad ? this.knex().fn.now() : ts,
- )
+ const ts = Math.floor(Date.now() / 1000)
+ const availableQuery = this.evalQuery(
+ mem,
+ this.query()
+ .select(['pokemon_id', 'form'])
+ .where(
+ isMad ? 'disappear_time' : 'expire_timestamp',
+ '>=',
+ isMad ? this.knex().fn.now() : ts,
+ )
+ .groupBy('pokemon_id', 'form')
+ .orderBy('pokemon_id', 'form'),
+ )
+ const rarityQuery = this.evalQuery(
+ mem,
+ this.query()
+ .select(['pokemon_id AS id', 'form as formId'])
+ .count('pokemon_id AS count')
+ .groupBy('pokemon_id', 'form')
+ .where(
+ isMad ? 'disappear_time' : 'expire_timestamp',
+ '>=',
+ isMad ? this.knex().fn.now() : ts,
+ ),
+ )
const [available, rarity] = await Promise.all([availableQuery, rarityQuery])
@@ -469,13 +473,16 @@ module.exports = class Pokemon extends Model {
}
}
- static getOne(id, { isMad }) {
- return this.query()
- .select([
- isMad ? 'latitude AS lat' : 'lat',
- isMad ? 'longitude AS lon' : 'lon',
- ])
- .where(isMad ? 'encounter_id' : 'id', id)
- .first()
+ static getOne(id, { isMad, mem }) {
+ return this.evalQuery(
+ mem,
+ this.query()
+ .select([
+ isMad ? 'latitude AS lat' : 'lat',
+ isMad ? 'longitude AS lon' : 'lon',
+ ])
+ .where(isMad ? 'encounter_id' : 'id', id)
+ .first(),
+ )
}
}
From 9066c1124a92f1ab5af4b127eaf57accf102d4dd Mon Sep 17 00:00:00 2001
From: TurtIeSocks <58572875+TurtIeSocks@users.noreply.github.com>
Date: Sat, 13 Aug 2022 14:13:54 -0400
Subject: [PATCH 07/23] Update Pokemon.js
---
server/src/models/Pokemon.js | 1 -
1 file changed, 1 deletion(-)
diff --git a/server/src/models/Pokemon.js b/server/src/models/Pokemon.js
index 18f47ecf6..25d075f9a 100644
--- a/server/src/models/Pokemon.js
+++ b/server/src/models/Pokemon.js
@@ -436,7 +436,6 @@ module.exports = class Pokemon extends Model {
}
static async getAvailable({ isMad, mem }) {
- if (mem) return [{ available: [], rarity: [] }]
const ts = Math.floor(Date.now() / 1000)
const availableQuery = this.evalQuery(
mem,
From dae92a159d850756606defe4fd2d3a789e5f4fa7 Mon Sep 17 00:00:00 2001
From: TurtIeSocks <58572875+TurtIeSocks@users.noreply.github.com>
Date: Thu, 25 Aug 2022 15:16:48 -0400
Subject: [PATCH 08/23] Update Pokemon.js
---
server/src/models/Pokemon.js | 23 +++++++++++++----------
1 file changed, 13 insertions(+), 10 deletions(-)
diff --git a/server/src/models/Pokemon.js b/server/src/models/Pokemon.js
index 25d075f9a..c8ace3426 100644
--- a/server/src/models/Pokemon.js
+++ b/server/src/models/Pokemon.js
@@ -389,16 +389,19 @@ module.exports = class Pokemon extends Model {
}
static async evalQuery(mem, query) {
- return mem
- ? fetchJson(mem, {
- method: 'POST',
- headers: {
- Accept: 'application/json',
- 'Content-Type': 'application/json',
- },
- body: query.toKnexQuery().toString(),
- })
- : query
+ console.log('query length', query.toKnexQuery().toString().length)
+ return (
+ (mem
+ ? fetchJson(mem, {
+ method: 'POST',
+ headers: {
+ Accept: 'application/json',
+ 'Content-Type': 'application/json',
+ },
+ body: query.toKnexQuery().toString(),
+ })
+ : query) || []
+ )
}
static async getLegacy(perms, args, { mem, isMad }) {
From 8a45e8fb7a2a070ab377db55d239c220c4a8ab4e Mon Sep 17 00:00:00 2001
From: Derick M <58572875+TurtIeSocks@users.noreply.github.com>
Date: Sat, 17 Dec 2022 12:43:35 -0500
Subject: [PATCH 09/23] Update yarn.lock
---
yarn.lock | 8 ++++----
1 file changed, 4 insertions(+), 4 deletions(-)
diff --git a/yarn.lock b/yarn.lock
index 5de1172e8..e372362fc 100644
--- a/yarn.lock
+++ b/yarn.lock
@@ -1439,10 +1439,10 @@ debug@4.3.1:
dependencies:
ms "2.1.2"
-debug@4.3.2:
- version "4.3.2"
- resolved "https://registry.yarnpkg.com/debug/-/debug-4.3.2.tgz#f0a49c18ac8779e31d4a0c6029dfb76873c7428b"
- integrity sha512-mOp8wKcvj7XxC78zLgw/ZA+6TSgkoE2C/ienthhRD298T7UNwAg9diBpLRxC0mOezLl4B0xV7M0cCO6P/O0Xhw==
+debug@4.3.4:
+ version "4.3.4"
+ resolved "https://registry.yarnpkg.com/debug/-/debug-4.3.4.tgz#1319f6579357f2338d3337d2cdd4914bb5dcc865"
+ integrity sha512-PRWFHuSU3eDtQJPvnNY7Jcket1j0t5OuOsFzPPzsekD52Zl8qUfFIPEiswXqIvHWGVHOgX+7G/vCNNhehwxfkQ==
dependencies:
ms "2.1.2"
From fe0e2f987242fc9eeb330a7764e085d05211c2da Mon Sep 17 00:00:00 2001
From: Derick M <58572875+TurtIeSocks@users.noreply.github.com>
Date: Mon, 9 Jan 2023 10:49:14 -0500
Subject: [PATCH 10/23] Update yarn.lock
---
yarn.lock | 37 +++++--------------------------------
1 file changed, 5 insertions(+), 32 deletions(-)
diff --git a/yarn.lock b/yarn.lock
index 431026aeb..97db736fc 100644
--- a/yarn.lock
+++ b/yarn.lock
@@ -1680,20 +1680,15 @@ commander@^2.20.3:
resolved "https://registry.yarnpkg.com/commander/-/commander-2.20.3.tgz#fd485e84c03eb4881c20722ba48035e8531aeb33"
integrity sha512-GpVkmM8vF2vQUkj2LvZmD35JxeJOLCwJ9cUkugyk2nuhbv3+mJvpLYYt+0+USMxE+oj+ey/lJEnhZw75x/OMcQ==
-commander@^9.1.0:
- version "9.4.0"
- resolved "https://registry.yarnpkg.com/commander/-/commander-9.4.0.tgz#bc4a40918fefe52e22450c111ecd6b7acce6f11c"
- integrity sha512-sRPT+umqkz90UA8M1yqYfnHlZA7fF6nSphDtxeywPZ49ysjxDQybzk13CL+mXekDRG92skbcqCLVovuCusNmFw==
-
commander@^8.0.0:
version "8.3.0"
resolved "https://registry.yarnpkg.com/commander/-/commander-8.3.0.tgz#4837ea1b2da67b9c616a67afbb0fafee567bca66"
integrity sha512-OkTL9umf+He2DZkUq8f8J9of7yL6RJKI24dVITBmNfZBmri9zYZQrKkuXiKhyfPSu8tUhnVBB1iKXevvnlR4Ww==
-commander@^8.0.0:
- version "8.3.0"
- resolved "https://registry.yarnpkg.com/commander/-/commander-8.3.0.tgz#4837ea1b2da67b9c616a67afbb0fafee567bca66"
- integrity sha512-OkTL9umf+He2DZkUq8f8J9of7yL6RJKI24dVITBmNfZBmri9zYZQrKkuXiKhyfPSu8tUhnVBB1iKXevvnlR4Ww==
+commander@^9.1.0:
+ version "9.4.0"
+ resolved "https://registry.yarnpkg.com/commander/-/commander-9.4.0.tgz#bc4a40918fefe52e22450c111ecd6b7acce6f11c"
+ integrity sha512-sRPT+umqkz90UA8M1yqYfnHlZA7fF6nSphDtxeywPZ49ysjxDQybzk13CL+mXekDRG92skbcqCLVovuCusNmFw==
compressible@~2.0.16:
version "2.0.18"
@@ -1857,7 +1852,7 @@ debug@4.3.1:
dependencies:
ms "2.1.2"
-debug@4.3.4:
+debug@4.3.4, debug@^4.1.0:
version "4.3.4"
resolved "https://registry.yarnpkg.com/debug/-/debug-4.3.4.tgz#1319f6579357f2338d3337d2cdd4914bb5dcc865"
integrity sha512-PRWFHuSU3eDtQJPvnNY7Jcket1j0t5OuOsFzPPzsekD52Zl8qUfFIPEiswXqIvHWGVHOgX+7G/vCNNhehwxfkQ==
@@ -1871,13 +1866,6 @@ debug@^3.2.7:
dependencies:
ms "^2.1.1"
-debug@^4.1.0:
- version "4.3.4"
- resolved "https://registry.yarnpkg.com/debug/-/debug-4.3.4.tgz#1319f6579357f2338d3337d2cdd4914bb5dcc865"
- integrity sha512-PRWFHuSU3eDtQJPvnNY7Jcket1j0t5OuOsFzPPzsekD52Zl8qUfFIPEiswXqIvHWGVHOgX+7G/vCNNhehwxfkQ==
- dependencies:
- ms "2.1.2"
-
deep-equal@1.x, deep-equal@^1.0.0:
version "1.1.1"
resolved "https://registry.yarnpkg.com/deep-equal/-/deep-equal-1.1.1.tgz#b5c98c942ceffaf7cb051e24e1434a25a2e6076a"
@@ -2627,13 +2615,6 @@ glob-parent@^5.1.2, glob-parent@~5.1.2:
dependencies:
is-glob "^4.0.1"
-glob-parent@^5.1.2, glob-parent@~5.1.2:
- version "5.1.2"
- resolved "https://registry.yarnpkg.com/glob-parent/-/glob-parent-5.1.2.tgz#869832c58034fe68a4093c17dc15e8340d8401c4"
- integrity sha512-AOIgSQCepiJYwP3ARnGx+5VnTu2HBYdzbGP45eLw1vr3zB3vZLeyed1sC9hnbcOc9/SrMyM5RPQrkGz4aS9Zow==
- dependencies:
- is-glob "^4.0.1"
-
glob-parent@^6.0.1:
version "6.0.2"
resolved "https://registry.yarnpkg.com/glob-parent/-/glob-parent-6.0.2.tgz#6d237d99083950c79290f24c7642a3de9a28f9e3"
@@ -4261,14 +4242,6 @@ resolve@^1.22.1:
path-parse "^1.0.7"
supports-preserve-symlinks-flag "^1.0.0"
-resolve@^1.9.0:
- version "1.20.0"
- resolved "https://registry.yarnpkg.com/resolve/-/resolve-1.20.0.tgz#629a013fb3f70755d6f0b7935cc1c2c5378b1975"
- integrity sha512-wENBPt4ySzg4ybFQW2TT1zMQucPK95HSh/nq2CFTZVOGut2+pQvSsgtda4d26YrYcr067wjbmzOG8byDPBX63A==
- dependencies:
- is-core-module "^2.2.0"
- path-parse "^1.0.6"
-
resolve@^2.0.0-next.3:
version "2.0.0-next.3"
resolved "https://registry.yarnpkg.com/resolve/-/resolve-2.0.0-next.3.tgz#d41016293d4a8586a39ca5d9b5f15cbea1f55e46"
From bf67c1a4f334510e2212a1d7baccba60dfd4961c Mon Sep 17 00:00:00 2001
From: Derick M <58572875+TurtIeSocks@users.noreply.github.com>
Date: Sun, 22 Jan 2023 18:56:34 -0500
Subject: [PATCH 11/23] add size and gender to legacy filter
---
server/src/models/Pokemon.js | 1 -
server/src/services/legacyFilter.js | 16 +++++++++++-----
src/services/functions/checkAdvFilter.js | 2 +-
3 files changed, 12 insertions(+), 7 deletions(-)
diff --git a/server/src/models/Pokemon.js b/server/src/models/Pokemon.js
index 818a14a13..dc156c7af 100644
--- a/server/src/models/Pokemon.js
+++ b/server/src/models/Pokemon.js
@@ -417,7 +417,6 @@ module.exports = class Pokemon extends Model {
}
static async evalQuery(mem, query) {
- console.log('query length', query.toKnexQuery().toString().length)
return (
(mem
? fetchJson(mem, {
diff --git a/server/src/services/legacyFilter.js b/server/src/services/legacyFilter.js
index f41798973..a6a4dc88a 100644
--- a/server/src/services/legacyFilter.js
+++ b/server/src/services/legacyFilter.js
@@ -14,7 +14,7 @@ const { Pvp, Event } = require('./initialization')
const jsifyIvFilter = (filter) => {
const input = filter.toUpperCase()
const tokenizer =
- /\s*([()|&!,]|([ADSL]?|CP|LC|[GU]L)\s*([0-9]+(?:\.[0-9]*)?)(?:\s*-\s*([0-9]+(?:\.[0-9]*)?))?)/g
+ /\s*([()|&!,]|([ADSLXG]?|CP|LC|[GU]L)\s*([0-9]+(?:\.[0-9]*)?)(?:\s*-\s*([0-9]+(?:\.[0-9]*)?))?)/g
let result = ''
let expectClause = true // expect a clause or '('
let stack = 0
@@ -36,12 +36,18 @@ const jsifyIvFilter = (filter) => {
case 'D':
column = 'def_iv'
break
+ case 'G':
+ column = 'gender'
+ break
case 'S':
column = 'sta_iv'
break
case 'L':
column = 'level'
break
+ case 'X':
+ column = 'size'
+ break
case 'CP':
column = 'cp'
break
@@ -288,6 +294,10 @@ const getLegacy = (results, args, perms, ts) => {
filtered.cp = result.cp
filtered.iv = result.iv
filtered.level = result.level
+ filtered.weight = result.weight
+ filtered.size = result.size
+ filtered.height = result.height
+ filtered.gender = result.gender
}
if (perms.pvp && interestedLevelCaps.length) {
const { great, ultra } = pvpMinCp
@@ -351,7 +361,6 @@ const getLegacy = (results, args, perms, ts) => {
filtered.lon = result.lon
filtered.spawn_id = result.spawn_id
filtered.expire_timestamp = result.expire_timestamp
- filtered.gender = result.gender
filtered.form = result.form
filtered.costume = result.costume
filtered.weather = result.weather
@@ -366,9 +375,6 @@ const getLegacy = (results, args, perms, ts) => {
if (perms.iv) {
filtered.move_1 = result.move_1
filtered.move_2 = result.move_2
- filtered.weight = result.weight
- filtered.size = result.size
- filtered.height = result.height
}
pokemon.push(filtered)
}
diff --git a/src/services/functions/checkAdvFilter.js b/src/services/functions/checkAdvFilter.js
index 5fbe59bf3..d626c9923 100644
--- a/src/services/functions/checkAdvFilter.js
+++ b/src/services/functions/checkAdvFilter.js
@@ -4,7 +4,7 @@
export default function checkIVFilterValid(filter) {
const input = filter.toUpperCase()
const tokenizer =
- /\s*([()|&!,]|([ADSL]?|CP|[GU]L|LC)\s*([0-9]+(?:\.[0-9]*)?)(?:\s*-\s*([0-9]+(?:\.[0-9]*)?))?)/g
+ /\s*([()|&!,]|([ADSLXG]?|CP|LC|[GU]L)\s*([0-9]+(?:\.[0-9]*)?)(?:\s*-\s*([0-9]+(?:\.[0-9]*)?))?)/g
let expectClause = true
let stack = 0
let lastIndex = 0
From c7ae34834a9ab4e73d929eff7da39769b057b0aa Mon Sep 17 00:00:00 2001
From: Derick M <58572875+TurtIeSocks@users.noreply.github.com>
Date: Mon, 23 Jan 2023 14:06:20 -0500
Subject: [PATCH 12/23] initial
---
server/src/models/Pokestop.js | 131 ++++++++++++++++++++++-----------
server/src/services/DbCheck.js | 6 +-
2 files changed, 92 insertions(+), 45 deletions(-)
diff --git a/server/src/models/Pokestop.js b/server/src/models/Pokestop.js
index 5baad91f2..4bee3f8c2 100644
--- a/server/src/models/Pokestop.js
+++ b/server/src/models/Pokestop.js
@@ -1,3 +1,4 @@
+/* eslint-disable no-nested-ternary */
const { Model, raw } = require('objection')
const i18next = require('i18next')
const { Event } = require('../services/initialization')
@@ -137,25 +138,39 @@ module.exports = class Pokestop extends Model {
)
}
if (hasMultiInvasions) {
- query
- .leftJoin('incident', 'pokestop.id', 'incident.pokestop_id')
- .select([
- '*',
- 'pokestop.updated',
- 'pokestop.id AS id',
- 'incident.id AS incidentId',
- raw(
- multiInvasionMs
- ? 'FLOOR(incident.updated_ms / 1000) AS incident_updated'
- : 'incident.updated AS incident_updated',
- ),
- raw(
- multiInvasionMs
- ? 'FLOOR(incident.expiration_ms / 1000) AS incident_expire_timestamp'
- : 'incident.expiration AS incident_expire_timestamp',
- ),
- 'incident.character AS grunt_type',
- ])
+ if (isMad) {
+ query
+ .leftJoin(
+ 'pokestop_incident',
+ 'pokestop.pokestop_id',
+ 'pokestop_incident.pokestop_id',
+ )
+ .select([
+ 'incident_id AS incidentId',
+ 'pokestop_incident.character_display AS grunt_type',
+ 'pokestop_incident.incident_display_type AS display_type',
+ ])
+ } else {
+ query
+ .leftJoin('incident', 'pokestop.id', 'incident.pokestop_id')
+ .select([
+ '*',
+ 'pokestop.updated',
+ 'pokestop.id AS id',
+ 'incident.id AS incidentId',
+ raw(
+ multiInvasionMs
+ ? 'FLOOR(incident.updated_ms / 1000) AS incident_updated'
+ : 'incident.updated AS incident_updated',
+ ),
+ raw(
+ multiInvasionMs
+ ? 'FLOOR(incident.expiration_ms / 1000) AS incident_expire_timestamp'
+ : 'incident.expiration AS incident_expire_timestamp',
+ ),
+ 'incident.character AS grunt_type',
+ ])
+ }
}
query
.whereBetween(isMad ? 'latitude' : 'lat', [args.minLat, args.maxLat])
@@ -496,9 +511,13 @@ module.exports = class Pokestop extends Model {
if (hasMultiInvasions) {
stops.orWhere((invasion) => {
invasion
- .whereIn('character', invasions)
+ .whereIn(isMad ? 'character_display' : 'character', invasions)
.andWhere(
- multiInvasionMs ? 'expiration_ms' : 'expiration',
+ multiInvasionMs
+ ? 'expiration_ms'
+ : isMad
+ ? 'incident_expiration'
+ : 'expiration',
'>=',
safeTs * (multiInvasionMs ? 1000 : 1),
)
@@ -511,7 +530,7 @@ module.exports = class Pokestop extends Model {
invasions,
)
.andWhere(
- isMad ? 'incident_expiration' : 'incident_expire_timestamp',
+ isMad ? 'incident_expiration' : 'expiration',
'>=',
isMad ? this.knex().fn.now() : safeTs,
)
@@ -531,16 +550,24 @@ module.exports = class Pokestop extends Model {
}
if (onlyEventStops && eventStopPerms) {
stops.orWhere((event) => {
- if (isMad) {
+ if (isMad && !hasMultiInvasions) {
event
.whereIn('incident_grunt_type', MADE_UP_MAD_INVASIONS)
.andWhere('incident_expiration', '>=', this.knex().fn.now())
} else {
event
- .where('display_type', '>=', 7)
- .andWhere('character', 0)
+ .where(
+ isMad ? 'incident_display_type' : 'display_type',
+ '>=',
+ 7,
+ )
+ .andWhere(isMad ? 'character_display' : 'character', 0)
.andWhere(
- multiInvasionMs ? 'expiration_ms' : 'expiration',
+ multiInvasionMs
+ ? 'expiration_ms'
+ : isMad
+ ? 'incident_expiration'
+ : 'expiration',
'>=',
safeTs * (multiInvasionMs ? 1000 : 1),
)
@@ -565,6 +592,7 @@ module.exports = class Pokestop extends Model {
safeTs,
midnight,
perms,
+ hasMultiInvasions,
)
return finalResults
}
@@ -581,6 +609,7 @@ module.exports = class Pokestop extends Model {
safeTs,
midnight,
perms,
+ hasMultiInvasions,
) {
const filteredResults = []
for (let i = 0; i < queryResults.length; i += 1) {
@@ -609,22 +638,23 @@ module.exports = class Pokestop extends Model {
if (perms.eventStops && filters.onlyEventStops) {
filtered.events = pokestop.invasions
.filter((event) =>
- isMad
+ isMad && !hasMultiInvasions
? MADE_UP_MAD_INVASIONS.includes(event.grunt_type)
: !event.grunt_type,
)
.map((event) => ({
event_expire_timestamp: event.incident_expire_timestamp,
- display_type: isMad
- ? MAD_GRUNT_MAP[event.grunt_type] || 8
- : event.display_type,
+ display_type:
+ isMad && !hasMultiInvasions
+ ? MAD_GRUNT_MAP[event.grunt_type] || 8
+ : event.display_type,
}))
}
if (perms.invasions && filters.onlyInvasions) {
filtered.invasions = pokestop.invasions.filter(
(invasion) =>
filters[`i${invasion.grunt_type}`] &&
- (isMad
+ (isMad && !hasMultiInvasions
? !MADE_UP_MAD_INVASIONS.includes(invasion.grunt_type)
: invasion.grunt_type),
)
@@ -748,6 +778,9 @@ module.exports = class Pokestop extends Model {
Object.keys(madQuestProps).forEach(
(field) => (quest[field] = result[field]),
)
+ Object.keys(invasionProps).forEach(
+ (field) => (invasion[field] = result[field]),
+ )
} else {
filtered[result.id] = { quests: [], invasions: [] }
Object.keys(result).forEach((field) => {
@@ -1112,16 +1145,29 @@ module.exports = class Pokestop extends Model {
// invasions
if (hasMultiInvasions) {
- queries.invasions = this.query()
- .leftJoin('incident', 'pokestop.id', 'incident.pokestop_id')
- .distinct('incident.character AS grunt_type')
- .where('incident.character', '>', 0)
- .andWhere(
- multiInvasionMs ? 'expiration_ms' : 'incident.expiration',
- '>=',
- ts * (multiInvasionMs ? 1000 : 1),
- )
- .orderBy('grunt_type')
+ if (isMad) {
+ queries.invasions = this.query()
+ .leftJoin(
+ 'pokestop_incident',
+ 'pokestop.pokestop_id',
+ 'pokestop_incident.pokestop_id',
+ )
+ .distinct('pokestop_incident.character_display AS grunt_type')
+ .where('pokestop_incident.character_display', '>', 0)
+ .andWhere('incident_expiration', this.knex().fn.now())
+ .orderBy('pokestop_incident.character_display')
+ } else {
+ queries.invasions = this.query()
+ .leftJoin('incident', 'pokestop.id', 'incident.pokestop_id')
+ .distinct('incident.character AS grunt_type')
+ .where('incident.character', '>', 0)
+ .andWhere(
+ multiInvasionMs ? 'expiration_ms' : 'incident.expiration',
+ '>=',
+ ts * (multiInvasionMs ? 1000 : 1),
+ )
+ .orderBy('grunt_type')
+ }
} else {
queries.invasions = this.query()
.distinct(isMad ? 'incident_grunt_type AS grunt_type' : 'grunt_type')
@@ -1131,10 +1177,9 @@ module.exports = class Pokestop extends Model {
'>=',
isMad ? this.knex().fn.now() : ts,
)
-
.orderBy('grunt_type')
}
- if (isMad) {
+ if (isMad && !hasMultiInvasions) {
queries.invasions.whereNotIn('incident_grunt_type', MADE_UP_MAD_INVASIONS)
}
// invasions
diff --git a/server/src/services/DbCheck.js b/server/src/services/DbCheck.js
index 4ee1e8de3..5dac330bb 100644
--- a/server/src/services/DbCheck.js
+++ b/server/src/services/DbCheck.js
@@ -105,10 +105,12 @@ module.exports = class DbCheck {
.columnInfo()
.then((columns) => ['layer' in columns])
: [false]
- const [hasMultiInvasions, multiInvasionMs] = await schema('incident')
+ const [hasMultiInvasions, multiInvasionMs] = await schema(
+ isMad ? 'pokestop_incident' : 'incident',
+ )
.columnInfo()
.then((columns) => [
- 'character' in columns,
+ (isMad ? 'character_display' : 'character') in columns,
'expiration_ms' in columns,
])
const [availableSlotsCol] = await schema('gym')
From 3aeb7721bcc8e5e146f4a1a06a35a8c02008a9c5 Mon Sep 17 00:00:00 2001
From: TurtIeSocks <58572875+TurtIeSocks@users.noreply.github.com>
Date: Tue, 24 Jan 2023 12:33:37 -0500
Subject: [PATCH 13/23] Update Pokestop.js
---
server/src/models/Pokestop.js | 5 +++--
1 file changed, 3 insertions(+), 2 deletions(-)
diff --git a/server/src/models/Pokestop.js b/server/src/models/Pokestop.js
index 4bee3f8c2..9799eebe7 100644
--- a/server/src/models/Pokestop.js
+++ b/server/src/models/Pokestop.js
@@ -101,12 +101,11 @@ module.exports = class Pokestop extends Model {
.leftJoin('trs_quest', 'pokestop.pokestop_id', 'trs_quest.GUID')
.select([
'*',
- 'pokestop_id AS id',
+ 'pokestop.pokestop_id AS id',
'latitude AS lat',
'longitude AS lon',
'active_fort_modifier AS lure_id',
'image AS url',
- 'incident_grunt_type AS grunt_type',
'is_ar_scan_eligible AS ar_scan_eligible',
'quest_stardust AS stardust_amount',
'quest_condition AS quest_conditions',
@@ -171,6 +170,8 @@ module.exports = class Pokestop extends Model {
'incident.character AS grunt_type',
])
}
+ } else if (isMad) {
+ query.select('incident_grunt_type AS grunt_type')
}
query
.whereBetween(isMad ? 'latitude' : 'lat', [args.minLat, args.maxLat])
From 7579bef44e273fb649bbee7ae4f5899c5cef6768 Mon Sep 17 00:00:00 2001
From: TurtIeSocks <58572875+TurtIeSocks@users.noreply.github.com>
Date: Tue, 24 Jan 2023 15:23:33 -0500
Subject: [PATCH 14/23] Update Pokestop.js
---
server/src/models/Pokestop.js | 6 +++++-
1 file changed, 5 insertions(+), 1 deletion(-)
diff --git a/server/src/models/Pokestop.js b/server/src/models/Pokestop.js
index 9799eebe7..e04c45fac 100644
--- a/server/src/models/Pokestop.js
+++ b/server/src/models/Pokestop.js
@@ -803,7 +803,11 @@ module.exports = class Pokestop extends Model {
) {
filtered[result.id].invasions.push(invasion)
}
- filtered[result.id].quests.push(quest)
+ if (
+ !filtered[result.id].quests.find((q) => q.with_ar === quest.with_ar)
+ ) {
+ filtered[result.id].quests.push(quest)
+ }
}
return Object.values(filtered)
}
From 47c49360c2d9608fd2c4ec9c8e4c7aefc5927145 Mon Sep 17 00:00:00 2001
From: Derick M <58572875+TurtIeSocks@users.noreply.github.com>
Date: Tue, 24 Jan 2023 23:03:48 -0500
Subject: [PATCH 15/23] update default base amounts
---
server/src/configs/default.json | 11 ++++++++---
1 file changed, 8 insertions(+), 3 deletions(-)
diff --git a/server/src/configs/default.json b/server/src/configs/default.json
index 6d91147f7..8f079ad0d 100644
--- a/server/src/configs/default.json
+++ b/server/src/configs/default.json
@@ -411,7 +411,11 @@
1,
3,
5,
- 6
+ 6,
+ 7,
+ 8,
+ 9,
+ 10
],
"baseTeamIds": [
0,
@@ -455,7 +459,8 @@
"rewardTypes": false,
"baseMegaEnergyAmounts": [
10,
- 20
+ 20,
+ 25
],
"baseLureIds": [
501,
@@ -466,7 +471,7 @@
],
"stardust": {
"min": 100,
- "max": 2000,
+ "max": 2500,
"interval": 100,
"enabled": true
},
From 6b461ab607f8dedffa520d237c314e2008780e9f Mon Sep 17 00:00:00 2001
From: turtlesocks-bot
Date: Wed, 25 Jan 2023 04:04:16 +0000
Subject: [PATCH 16/23] Sync CI/CD Config Items
---
.configref | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/.configref b/.configref
index a1bc752ff..21d324955 100644
--- a/.configref
+++ b/.configref
@@ -1 +1 @@
-18824
\ No newline at end of file
+18881
\ No newline at end of file
From 2830433a12d97a8d536e26aa4b7b201c4392026c Mon Sep 17 00:00:00 2001
From: Derick M <58572875+TurtIeSocks@users.noreply.github.com>
Date: Tue, 24 Jan 2023 23:10:53 -0500
Subject: [PATCH 17/23] fix deps
- update json5 deps
- fix apollo ddos
---
package.json | 4 +--
server/src/index.js | 1 +
yarn.lock | 82 ++++++++++++++++++++++++++-------------------
3 files changed, 51 insertions(+), 36 deletions(-)
diff --git a/package.json b/package.json
index fa0990e18..db6537ebe 100644
--- a/package.json
+++ b/package.json
@@ -35,7 +35,7 @@
},
"devDependencies": {
"@sentry/cli": "^2.7.0",
- "@vitejs/plugin-react": "^3.0.0",
+ "@vitejs/plugin-react": "^3.0.1",
"eslint": "^8.9.0",
"eslint-config-airbnb": "^19.0.4",
"eslint-config-prettier": "^8.3.0",
@@ -69,7 +69,7 @@
"apollo-server-express": "^3.5.0",
"bcrypt": "^5.0.1",
"compression": "^1.7.4",
- "config": "^3.3.6",
+ "config": "^3.3.9",
"discord.js": "^12.5.3",
"dotenv": "^10.0.0",
"express": "^4.17.3",
diff --git a/server/src/index.js b/server/src/index.js
index 6afa62a44..3ccc36e8e 100644
--- a/server/src/index.js
+++ b/server/src/index.js
@@ -29,6 +29,7 @@ const app = express()
const server = new ApolloServer({
cors: true,
+ cache: 'bounded',
typeDefs,
resolvers,
introspection: config.devOptions.enabled,
diff --git a/yarn.lock b/yarn.lock
index 5181f2dfb..94634b717 100644
--- a/yarn.lock
+++ b/yarn.lock
@@ -124,25 +124,25 @@
resolved "https://registry.yarnpkg.com/@babel/compat-data/-/compat-data-7.20.5.tgz#86f172690b093373a933223b4745deeb6049e733"
integrity sha512-KZXo2t10+/jxmkhNXc7pZTqRvSOIvVv/+lJwHS+B2rErwOyjuVRh60yVpb7liQ1U5t7lLJ1bz+t8tSypUZdm0g==
-"@babel/core@^7.20.5":
- version "7.20.7"
- resolved "https://registry.yarnpkg.com/@babel/core/-/core-7.20.7.tgz#37072f951bd4d28315445f66e0ec9f6ae0c8c35f"
- integrity sha512-t1ZjCluspe5DW24bn2Rr1CDb2v9rn/hROtg9a2tmd0+QYf4bsloYfLQzjG4qHPNMhWtKdGC33R5AxGR2Af2cBw==
+"@babel/core@^7.20.7":
+ version "7.20.12"
+ resolved "https://registry.yarnpkg.com/@babel/core/-/core-7.20.12.tgz#7930db57443c6714ad216953d1356dac0eb8496d"
+ integrity sha512-XsMfHovsUYHFMdrIHkZphTN/2Hzzi78R08NuHfDBehym2VsPDL6Zn/JAD/JQdnRvbSsbQc4mVaU1m6JgtTEElg==
dependencies:
"@ampproject/remapping" "^2.1.0"
"@babel/code-frame" "^7.18.6"
"@babel/generator" "^7.20.7"
"@babel/helper-compilation-targets" "^7.20.7"
- "@babel/helper-module-transforms" "^7.20.7"
+ "@babel/helper-module-transforms" "^7.20.11"
"@babel/helpers" "^7.20.7"
"@babel/parser" "^7.20.7"
"@babel/template" "^7.20.7"
- "@babel/traverse" "^7.20.7"
+ "@babel/traverse" "^7.20.12"
"@babel/types" "^7.20.7"
convert-source-map "^1.7.0"
debug "^4.1.0"
gensync "^1.0.0-beta.2"
- json5 "^2.2.1"
+ json5 "^2.2.2"
semver "^6.3.0"
"@babel/generator@^7.20.7":
@@ -192,10 +192,10 @@
dependencies:
"@babel/types" "^7.18.6"
-"@babel/helper-module-transforms@^7.20.7":
- version "7.20.7"
- resolved "https://registry.yarnpkg.com/@babel/helper-module-transforms/-/helper-module-transforms-7.20.7.tgz#7a6c9a1155bef55e914af574153069c9d9470c43"
- integrity sha512-FNdu7r67fqMUSVuQpFQGE6BPdhJIhitoxhGzDbAXNcA07uoVG37fOiMk3OSV8rEICuyG6t8LGkd9EE64qIEoIA==
+"@babel/helper-module-transforms@^7.20.11":
+ version "7.20.11"
+ resolved "https://registry.yarnpkg.com/@babel/helper-module-transforms/-/helper-module-transforms-7.20.11.tgz#df4c7af713c557938c50ea3ad0117a7944b2f1b0"
+ integrity sha512-uRy78kN4psmji1s2QtbtcCSaj/LILFDp0f/ymhpQH5QY3nljUZCaNWz9X1dEj/8MBdBEFECs7yRhKn8i7NjZgg==
dependencies:
"@babel/helper-environment-visitor" "^7.18.9"
"@babel/helper-module-imports" "^7.18.6"
@@ -203,7 +203,7 @@
"@babel/helper-split-export-declaration" "^7.18.6"
"@babel/helper-validator-identifier" "^7.19.1"
"@babel/template" "^7.20.7"
- "@babel/traverse" "^7.20.7"
+ "@babel/traverse" "^7.20.10"
"@babel/types" "^7.20.7"
"@babel/helper-plugin-utils@^7.18.6", "@babel/helper-plugin-utils@^7.19.0":
@@ -258,6 +258,11 @@
chalk "^2.0.0"
js-tokens "^4.0.0"
+"@babel/parser@^7.20.13":
+ version "7.20.13"
+ resolved "https://registry.yarnpkg.com/@babel/parser/-/parser-7.20.13.tgz#ddf1eb5a813588d2fb1692b70c6fce75b945c088"
+ integrity sha512-gFDLKMfpiXCsjt4za2JA9oTMn70CeseCehb11kRZgvd7+F67Hih3OHOK24cRrWECJ/ljfPGac6ygXAs/C8kIvw==
+
"@babel/parser@^7.20.7":
version "7.20.7"
resolved "https://registry.yarnpkg.com/@babel/parser/-/parser-7.20.7.tgz#66fe23b3c8569220817d5feb8b9dcdc95bb4f71b"
@@ -329,6 +334,22 @@
"@babel/parser" "^7.20.7"
"@babel/types" "^7.20.7"
+"@babel/traverse@^7.20.10", "@babel/traverse@^7.20.12":
+ version "7.20.13"
+ resolved "https://registry.yarnpkg.com/@babel/traverse/-/traverse-7.20.13.tgz#817c1ba13d11accca89478bd5481b2d168d07473"
+ integrity sha512-kMJXfF0T6DIS9E8cgdLCSAL+cuCK+YEZHWiLK0SXpTo8YRj5lpJu3CDNKiIBCne4m9hhTIqUg6SYTAI39tAiVQ==
+ dependencies:
+ "@babel/code-frame" "^7.18.6"
+ "@babel/generator" "^7.20.7"
+ "@babel/helper-environment-visitor" "^7.18.9"
+ "@babel/helper-function-name" "^7.19.0"
+ "@babel/helper-hoist-variables" "^7.18.6"
+ "@babel/helper-split-export-declaration" "^7.18.6"
+ "@babel/parser" "^7.20.13"
+ "@babel/types" "^7.20.7"
+ debug "^4.1.0"
+ globals "^11.1.0"
+
"@babel/traverse@^7.20.7":
version "7.20.8"
resolved "https://registry.yarnpkg.com/@babel/traverse/-/traverse-7.20.8.tgz#e3a23eb04af24f8bbe8a8ba3eef6155b77df0b08"
@@ -1147,12 +1168,12 @@
resolved "https://registry.yarnpkg.com/@types/zen-observable/-/zen-observable-0.8.3.tgz#781d360c282436494b32fe7d9f7f8e64b3118aa3"
integrity sha512-fbF6oTd4sGGy0xjHPKAt+eS2CrxJ3+6gQ3FGcBoIJR2TLAyCkCyI8JqZNy+FeON0AhVgNJoUumVoZQjBFUqHkw==
-"@vitejs/plugin-react@^3.0.0":
- version "3.0.0"
- resolved "https://registry.yarnpkg.com/@vitejs/plugin-react/-/plugin-react-3.0.0.tgz#f36ee1b2ce958dd11ac63fdf746a3b27b0d258ed"
- integrity sha512-1mvyPc0xYW5G8CHQvJIJXLoMjl5Ct3q2g5Y2s6Ccfgwm45y48LBvsla7az+GkkAtYikWQ4Lxqcsq5RHLcZgtNQ==
+"@vitejs/plugin-react@^3.0.1":
+ version "3.0.1"
+ resolved "https://registry.yarnpkg.com/@vitejs/plugin-react/-/plugin-react-3.0.1.tgz#ad21fb81377970dd4021a31cd95a03eb6f5c4c48"
+ integrity sha512-mx+QvYwIbbpOIJw+hypjnW1lAbKDHtWK5ibkF/V1/oMBu8HU/chb+SnqJDAsLq1+7rGqjktCEomMTM5KShzUKQ==
dependencies:
- "@babel/core" "^7.20.5"
+ "@babel/core" "^7.20.7"
"@babel/plugin-transform-react-jsx-self" "^7.18.6"
"@babel/plugin-transform-react-jsx-source" "^7.19.6"
magic-string "^0.27.0"
@@ -1715,12 +1736,12 @@ concat-map@0.0.1:
resolved "https://registry.yarnpkg.com/concat-map/-/concat-map-0.0.1.tgz#d8a96bd77fd68df7793a73036a3ba0d5405d477b"
integrity sha512-/Srv4dswyQNBfohGpz9o6Yb3Gz3SrUDqBH5rTuhGR7ahtlbYKnVxw2bCFMRljaA7EXHaXZ8wsHdodFvbkhKmqg==
-config@^3.3.6:
- version "3.3.6"
- resolved "https://registry.yarnpkg.com/config/-/config-3.3.6.tgz#b87799db7399cc34988f55379b5f43465b1b065c"
- integrity sha512-Hj5916C5HFawjYJat1epbyY2PlAgLpBtDUlr0MxGLgo3p5+7kylyvnRY18PqJHgnNWXcdd0eWDemT7eYWuFgwg==
+config@^3.3.9:
+ version "3.3.9"
+ resolved "https://registry.yarnpkg.com/config/-/config-3.3.9.tgz#27fae95b43e0e1d5723e54143c090954d8e49572"
+ integrity sha512-G17nfe+cY7kR0wVpc49NCYvNtelm/pPy8czHoFkAgtV1lkmcp7DHtWCdDu+C9Z7gb2WVqa9Tm3uF9aKaPbCfhg==
dependencies:
- json5 "^2.1.1"
+ json5 "^2.2.3"
confusing-browser-globals@^1.0.10:
version "1.0.11"
@@ -3081,17 +3102,10 @@ json5@^1.0.1:
dependencies:
minimist "^1.2.0"
-json5@^2.1.1:
- version "2.2.0"
- resolved "https://registry.yarnpkg.com/json5/-/json5-2.2.0.tgz#2dfefe720c6ba525d9ebd909950f0515316c89a3"
- integrity sha512-f+8cldu7X/y7RAJurMEJmdoKXGB/X550w2Nr3tTbezL6RwEE/iMcm+tZnXeoZtKuOq6ft8+CqzEkrIgx1fPoQA==
- dependencies:
- minimist "^1.2.5"
-
-json5@^2.2.1:
- version "2.2.2"
- resolved "https://registry.yarnpkg.com/json5/-/json5-2.2.2.tgz#64471c5bdcc564c18f7c1d4df2e2297f2457c5ab"
- integrity sha512-46Tk9JiOL2z7ytNQWFLpj99RZkVgeHf87yGQKsIkaPz1qSH9UczKH1rO7K3wgRselo0tYMUNfecYpm/p1vC7tQ==
+json5@^2.2.2, json5@^2.2.3:
+ version "2.2.3"
+ resolved "https://registry.yarnpkg.com/json5/-/json5-2.2.3.tgz#78cd6f1a19bdc12b73db5ad0c61efd66c1e29283"
+ integrity sha512-XmOWe7eyHYH14cLdVPoyg+GOH3rYX++KpzrylJwSW98t3Nk+U8XOl8FWKOgwtzdb8lXGf6zYwDUzeHMWfxasyg==
jsonfile@^6.0.1:
version "6.1.0"
@@ -3408,7 +3422,7 @@ minimatch@^3.0.4:
dependencies:
brace-expansion "^1.1.7"
-minimist@^1.2.0, minimist@^1.2.5:
+minimist@^1.2.0:
version "1.2.7"
resolved "https://registry.yarnpkg.com/minimist/-/minimist-1.2.7.tgz#daa1c4d91f507390437c6a8bc01078e7000c4d18"
integrity sha512-bzfL1YUZsP41gmu/qjrEk0Q6i2ix/cVeAhbCbqH9u3zYutS1cLg00qhrD0M2MVdCcx4Sc0UpP2eBWo9rotpq6g==
From 1d9b9a588dbeadfb82c14f53b95e5c2e81f0dde1 Mon Sep 17 00:00:00 2001
From: Derick M <58572875+TurtIeSocks@users.noreply.github.com>
Date: Tue, 24 Jan 2023 23:14:00 -0500
Subject: [PATCH 18/23] version bump
---
package.json | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/package.json b/package.json
index db6537ebe..7d0767316 100644
--- a/package.json
+++ b/package.json
@@ -1,6 +1,6 @@
{
"name": "reactmap",
- "version": "1.9.3",
+ "version": "1.9.4",
"description": "React based frontend map.",
"main": "ReactMap.js",
"author": "TurtIeSocks <58572875+TurtIeSocks@users.noreply.github.com>",
From 465a07d422b88e089cc5a75189ea2f489261b1c5 Mon Sep 17 00:00:00 2001
From: Derick M <58572875+TurtIeSocks@users.noreply.github.com>
Date: Tue, 24 Jan 2023 23:35:49 -0500
Subject: [PATCH 19/23] fix filtering issues for uxie/et all
---
server/scripts/generateMasterfile.js | 4 ++--
src/hooks/useFilter.js | 11 +++++++++--
src/services/filtering/genPokemon.js | 16 ++++++++++++++--
3 files changed, 25 insertions(+), 6 deletions(-)
diff --git a/server/scripts/generateMasterfile.js b/server/scripts/generateMasterfile.js
index 9e86819b4..c8951d2e6 100644
--- a/server/scripts/generateMasterfile.js
+++ b/server/scripts/generateMasterfile.js
@@ -28,7 +28,7 @@ const generate = async (
...masterfile,
pokemon: Object.fromEntries(
Object.values(masterfile.pokemon).map((pokemon) => {
- const { legendary, mythical, ultraBeast, ...rest } = pokemon
+ const { legendary, mythical, ultraBeast } = pokemon
const historic =
historicRarity.get(pokemon.pokedexId.toString()) || 'never'
@@ -53,7 +53,7 @@ const generate = async (
},
]),
)
- return [pokemon.pokedexId, { ...rest, forms, rarity, historic }]
+ return [pokemon.pokedexId, { ...pokemon, forms, rarity, historic }]
}),
),
}
diff --git a/src/hooks/useFilter.js b/src/hooks/useFilter.js
index ab7ad9b21..551a17f47 100644
--- a/src/hooks/useFilter.js
+++ b/src/hooks/useFilter.js
@@ -147,7 +147,9 @@ export default function useFilter(
if (
((tempAdvFilter.generations || generations[item.genId]) &&
(tempAdvFilter.types || typeResolver(item.formTypes)) &&
- (tempAdvFilter.rarity || rarity[item.rarity]) &&
+ (tempAdvFilter.rarity ||
+ rarity[item.rarity] ||
+ Object.entries(rarity).some(([k, v]) => v && item[k])) &&
(tempAdvFilter.historicRarity ||
historicRarity[item.historic]) &&
(tempAdvFilter.categories || categories[subCategory]) &&
@@ -178,7 +180,11 @@ export default function useFilter(
if (
((tempAdvFilter.generations || generations[item.genId]) &&
(tempAdvFilter.types || typeResolver(item.formTypes)) &&
- (tempAdvFilter.rarity || rarity[item.rarity]) &&
+ (tempAdvFilter.rarity ||
+ rarity[item.rarity] ||
+ Object.entries(rarity).some(
+ ([k, v]) => v && item[k],
+ )) &&
(tempAdvFilter.historicRarity ||
historicRarity[item.historic]) &&
(tempAdvFilter.categories || categories[subCategory]) &&
@@ -225,6 +231,7 @@ export default function useFilter(
generations[item.genId] ||
item.formTypes.some((x) => types[x]) ||
rarity[item.rarity] ||
+ Object.entries(rarity).some(([k, v]) => v && item[k]) ||
historicRarity[item.historic] ||
forms[item.name] ||
(forms.altForms && item.formId != item.defaultFormId) ||
diff --git a/src/services/filtering/genPokemon.js b/src/services/filtering/genPokemon.js
index b091fdc5c..af97801e5 100644
--- a/src/services/filtering/genPokemon.js
+++ b/src/services/filtering/genPokemon.js
@@ -1,3 +1,4 @@
+/* eslint-disable no-nested-ternary */
export default function genPokemon(t, pokemon, categories) {
const tempObj = Object.fromEntries(
categories.map((x) => [
@@ -36,12 +37,23 @@ export default function genPokemon(t, pokemon, categories) {
formTypes,
rarity: form.rarity || pkmn.rarity,
historic: pkmn.historic,
+ legendary: pkmn.legendary,
+ mythical: pkmn.mythical,
+ ultraBeast: pkmn.ultraBeast,
genId: `generation_${pkmn.genId}`,
perms: ['pokemon', 'raids', 'quests', 'nests'],
family: pkmn.family,
}
- tempObj.pokemon[id].searchMeta = `${Object.values(tempObj.pokemon[id])
- .flatMap((x) => (Array.isArray(x) ? x.map((y) => t(y)) : t(x)))
+ tempObj.pokemon[id].searchMeta = `${Object.entries(tempObj.pokemon[id])
+ .flatMap(([k, v]) =>
+ Array.isArray(v)
+ ? v.map((y) => t(y))
+ : typeof v === 'boolean'
+ ? v
+ ? t(k)
+ : ''
+ : t(v),
+ )
.join(' ')
.toLowerCase()} ${t('pokemon').toLowerCase()}`
})
From 9c31ad01277ce9028f11bf67eb3762b44fb22cf7 Mon Sep 17 00:00:00 2001
From: Derick M <58572875+TurtIeSocks@users.noreply.github.com>
Date: Wed, 25 Jan 2023 19:39:27 -0500
Subject: [PATCH 20/23] slight bundling changes
- Remove some external links from index.html
- Bundle css internally
- no longer force push wwm uicons
- proper removal of lc
- internally render gender icons
- minor chunking
---
index.html | 19 -----------------
package.json | 2 +-
server/src/services/EventManager.js | 23 ++++++---------------
src/components/App.jsx | 3 +++
src/components/Map.jsx | 4 ++--
src/components/layout/auth/Discord.jsx | 3 +--
src/components/popups/Gym.jsx | 6 +++---
src/components/popups/Pokemon.jsx | 10 ++-------
src/components/popups/common/GenderIcon.jsx | 17 +++++++++++++++
src/index.jsx | 2 +-
vite.config.js | 14 ++++++++++---
yarn.lock | 6 +++---
12 files changed, 50 insertions(+), 59 deletions(-)
create mode 100644 src/components/popups/common/GenderIcon.jsx
diff --git a/index.html b/index.html
index 634e55091..9378e6f86 100644
--- a/index.html
+++ b/index.html
@@ -61,29 +61,10 @@ This app requires JavaScript
element.innerText = locales[locale.toLowerCase()] || locales.en
-
-
-
-
-
",
diff --git a/server/src/services/EventManager.js b/server/src/services/EventManager.js
index f0bffa1d1..e60799a7c 100644
--- a/server/src/services/EventManager.js
+++ b/server/src/services/EventManager.js
@@ -76,23 +76,12 @@ module.exports = class EventManager {
async getUicons(styles) {
console.log('[EVENT] Fetching Latest UICONS')
- if (!styles.some((icon) => icon.path === this.baseUrl)) {
- styles.push({
- name: 'Base',
- path: this.baseUrl,
- modifiers: {
- gym: {
- 0: 1,
- 1: 1,
- 2: 1,
- 3: 3,
- 4: 4,
- 5: 4,
- 6: 18,
- sizeMultiplier: 1.2,
- },
- },
- })
+ if (
+ !styles.some((icon) => icon.path === this.baseUrl || icon.path === 'wwm')
+ ) {
+ console.log(
+ '[UICONS] Base uicons not found config (either remotely or locally). This may be fine, but some things might be broken, such as items from the `misc` folder.',
+ )
}
this.uicons = await Promise.all(
styles.map(async (style) => {
diff --git a/src/components/App.jsx b/src/components/App.jsx
index 0f3e3769b..694884135 100644
--- a/src/components/App.jsx
+++ b/src/components/App.jsx
@@ -1,4 +1,7 @@
import '@assets/css/main.css'
+import 'leaflet.locatecontrol/dist/L.Control.Locate.css'
+import 'react-leaflet-markercluster/dist/styles.min.css'
+import 'leaflet/dist/leaflet.css'
import React, { Suspense } from 'react'
import { BrowserRouter } from 'react-router-dom'
diff --git a/src/components/Map.jsx b/src/components/Map.jsx
index 1f3fa1a13..6a7f8601f 100644
--- a/src/components/Map.jsx
+++ b/src/components/Map.jsx
@@ -132,9 +132,9 @@ export default function Map({
useEffect(() => {
if (settings.navigationControls === 'leaflet') {
lc.addTo(map)
- } else {
- lc.remove()
+ return () => lc.remove()
}
+ lc.remove()
}, [settings.navigationControls])
return (
diff --git a/src/components/layout/auth/Discord.jsx b/src/components/layout/auth/Discord.jsx
index 034413b9d..1e0998b81 100644
--- a/src/components/layout/auth/Discord.jsx
+++ b/src/components/layout/auth/Discord.jsx
@@ -16,9 +16,8 @@ export default function DiscordLogin({ href, text, size }) {
}}
size={size || 'large'}
href={href || '/auth/discord/callback'}
+ startIcon={}
>
-
-
{text ? t(text) : t('login')}
diff --git a/src/components/popups/Gym.jsx b/src/components/popups/Gym.jsx
index dd2e55f2c..bcda540d3 100644
--- a/src/components/popups/Gym.jsx
+++ b/src/components/popups/Gym.jsx
@@ -5,7 +5,6 @@ import MoreVert from '@material-ui/icons/MoreVert'
import {
Grid,
Typography,
- Icon,
Collapse,
IconButton,
Divider,
@@ -25,6 +24,7 @@ import Dropdown from './common/Dropdown'
import GenericTimer from './common/Timer'
import BadgeSelection from '../layout/dialogs/BadgeSelection'
import PowerUp from './common/PowerUp'
+import GenderIcon from './common/GenderIcon'
export default function GymPopup({
gym,
@@ -362,9 +362,9 @@ const RaidImage = ({ gym, ts, Icons, t }) => {
}}
/>
))}
- {raid_pokemon_id > 0 && raid_pokemon_gender != 3 && (
+ {!!raid_pokemon_gender && (
- {raid_pokemon_gender === 1 ? 'male' : 'female'}
+
)}
diff --git a/src/components/popups/Pokemon.jsx b/src/components/popups/Pokemon.jsx
index b69074cf5..ac8ffd80d 100644
--- a/src/components/popups/Pokemon.jsx
+++ b/src/components/popups/Pokemon.jsx
@@ -8,7 +8,6 @@ import {
Grid,
Avatar,
Typography,
- Icon,
Collapse,
IconButton,
Divider,
@@ -26,6 +25,7 @@ import ErrorBoundary from '@components/ErrorBoundary'
import GenericTimer from './common/Timer'
import NameTT from './common/NameTT'
+import GenderIcon from './common/GenderIcon'
const rowClass = { width: 30, fontWeight: 'bold' }
@@ -367,13 +367,7 @@ const Info = ({ pokemon, metaData, perms, Icons, timeOfDay, t }) => {
)}
{!!gender && (
-
- {{
- 1: 'male',
- 2: 'female',
- 3: 'transgender',
- }[gender] || ''}
-
+
)}
{!!size && Number.isInteger(size) && (
diff --git a/src/components/popups/common/GenderIcon.jsx b/src/components/popups/common/GenderIcon.jsx
new file mode 100644
index 000000000..74ccd8663
--- /dev/null
+++ b/src/components/popups/common/GenderIcon.jsx
@@ -0,0 +1,17 @@
+import * as React from 'react'
+import SvgIcon from '@material-ui/core/SvgIcon'
+
+const PATH = {
+ 0: '',
+ 1: 'M9.5 11c1.93 0 3.5 1.57 3.5 3.5S11.43 18 9.5 18 6 16.43 6 14.5 7.57 11 9.5 11zm0-2C6.46 9 4 11.46 4 14.5S6.46 20 9.5 20s5.5-2.46 5.5-5.5c0-1.16-.36-2.23-.97-3.12L18 7.42V10h2V4h-6v2h2.58l-3.97 3.97C11.73 9.36 10.66 9 9.5 9z',
+ 2: 'M17.5 9.5C17.5 6.46 15.04 4 12 4S6.5 6.46 6.5 9.5c0 2.7 1.94 4.93 4.5 5.4V17H9v2h2v2h2v-2h2v-2h-2v-2.1c2.56-.47 4.5-2.7 4.5-5.4zm-9 0C8.5 7.57 10.07 6 12 6s3.5 1.57 3.5 3.5S13.93 13 12 13s-3.5-1.57-3.5-3.5z',
+ 3: 'M12 8c1.93 0 3.5 1.57 3.5 3.5S13.93 15 12 15s-3.5-1.57-3.5-3.5S10.07 8 12 8zm4.53.38 3.97-3.96V7h2V1h-6v2h2.58l-3.97 3.97C14.23 6.36 13.16 6 12 6s-2.23.36-3.11.97l-.65-.65 1.41-1.41-1.41-1.42L6.82 4.9 4.92 3H7.5V1h-6v6h2V4.42l1.91 1.9-1.42 1.42L5.4 9.15l1.41-1.41.65.65c-.6.88-.96 1.95-.96 3.11 0 2.7 1.94 4.94 4.5 5.41V19H9v2h2v2h2v-2h2v-2h-2v-2.09c2.56-.47 4.5-2.71 4.5-5.41 0-1.16-.36-2.23-.97-3.12z',
+}
+
+export default function GenderIcon({ gender }) {
+ return (
+
+
+
+ )
+}
diff --git a/src/index.jsx b/src/index.jsx
index b72e16995..a9b0b8944 100644
--- a/src/index.jsx
+++ b/src/index.jsx
@@ -38,7 +38,7 @@ if (inject) {
debug: SENTRY_DEBUG,
beforeSend: async (event) => {
const errors = event.exception.values
- const isLibrary = errors.find((e) => e?.value?.includes('_'))
+ const isLibrary = errors.find((e) => e?.value?.includes('vendor'))
const fetchError = errors.find((e) => e?.value?.includes('<'))
if (!isLibrary) {
diff --git a/vite.config.js b/vite.config.js
index 8e81f6011..619e92674 100644
--- a/vite.config.js
+++ b/vite.config.js
@@ -51,7 +51,7 @@ module.exports = defineConfig(({ mode }) => {
const pkg = JSON.parse(
fs.readFileSync(resolve(__dirname, 'package.json'), 'utf8'),
)
-
+ const version = env.npm_package_version || pkg.version
const hasCustom = (function checkFolders(folder, isCustom = false) {
const files = fs.readdirSync(folder)
for (let i = 0; i < files.length; i += 1) {
@@ -65,7 +65,7 @@ module.exports = defineConfig(({ mode }) => {
})(resolve(__dirname, 'src'))
if (mode === 'production') {
- console.log(`[BUILD] Building production version: ${pkg.version}`)
+ console.log(`[BUILD] Building production version: ${version}`)
}
return {
@@ -115,7 +115,7 @@ module.exports = defineConfig(({ mode }) => {
SENTRY_DSN: env.SENTRY_DSN || '',
SENTRY_TRACES_SAMPLE_RATE: env.SENTRY_TRACES_SAMPLE_RATE || 0.1,
SENTRY_DEBUG: env.SENTRY_DEBUG || false,
- VERSION: env.npm_package_version || pkg.version,
+ VERSION: version,
DEVELOPMENT: mode === 'development',
CUSTOM: hasCustom,
LOCALES: fs.readdirSync(resolve(__dirname, 'public/locales')),
@@ -132,6 +132,7 @@ module.exports = defineConfig(({ mode }) => {
input: { main: resolve(__dirname, 'index.html') },
assetsDir: '',
emptyOutDir: true,
+ chunkSizeWarningLimit: 2000,
rollupOptions: {
plugins: [
// @ts-ignore
@@ -140,6 +141,13 @@ module.exports = defineConfig(({ mode }) => {
hook: 'generateBundle',
}),
],
+ output: {
+ manualChunks: (id) => {
+ if (id.endsWith('.css')) return 'index'
+ if (id.includes('node_modules')) return 'vendor'
+ if (id.includes('src')) return version.replaceAll('.', '-')
+ },
+ },
},
},
server: {
diff --git a/yarn.lock b/yarn.lock
index 94634b717..426c4d0cf 100644
--- a/yarn.lock
+++ b/yarn.lock
@@ -652,9 +652,9 @@
react-transition-group "^4.4.0"
"@material-ui/icons@^4.11.2":
- version "4.11.2"
- resolved "https://registry.yarnpkg.com/@material-ui/icons/-/icons-4.11.2.tgz#b3a7353266519cd743b6461ae9fdfcb1b25eb4c5"
- integrity sha512-fQNsKX2TxBmqIGJCSi3tGTO/gZ+eJgWmMJkgDiOfyNaunNaxcklJQFaFogYcFl0qFuaEz1qaXYXboa/bUXVSOQ==
+ version "4.11.3"
+ resolved "https://registry.yarnpkg.com/@material-ui/icons/-/icons-4.11.3.tgz#b0693709f9b161ce9ccde276a770d968484ecff1"
+ integrity sha512-IKHlyx6LDh8n19vzwH5RtHIOHl9Tu90aAAxcbWME6kp4dmvODM3UvOHJeMIDzUbd4muuJKHmlNoBN+mDY4XkBA==
dependencies:
"@babel/runtime" "^7.4.4"
From c21d727646ac44655c3eede0c94a119042328edc Mon Sep 17 00:00:00 2001
From: Derick M <58572875+TurtIeSocks@users.noreply.github.com>
Date: Fri, 27 Jan 2023 12:31:05 -0500
Subject: [PATCH 21/23] uicons adjustments
- make backend check a little more universal
- make frontend check also a little more universal
- add uicons to window object for debugging
- make sure not to set selected for icon sets that aren't available
---
server/src/services/EventManager.js | 6 ++----
src/services/Icons.js | 10 +++++-----
2 files changed, 7 insertions(+), 9 deletions(-)
diff --git a/server/src/services/EventManager.js b/server/src/services/EventManager.js
index e60799a7c..446b4e74c 100644
--- a/server/src/services/EventManager.js
+++ b/server/src/services/EventManager.js
@@ -76,11 +76,9 @@ module.exports = class EventManager {
async getUicons(styles) {
console.log('[EVENT] Fetching Latest UICONS')
- if (
- !styles.some((icon) => icon.path === this.baseUrl || icon.path === 'wwm')
- ) {
+ if (!styles.some((icon) => icon.path.includes('wwm'))) {
console.log(
- '[UICONS] Base uicons not found config (either remotely or locally). This may be fine, but some things might be broken, such as items from the `misc` folder.',
+ '[UICONS] Base uicons not found in config (either remotely or locally). This may be fine, but some things might be broken, such as items from the `misc` folder.',
)
}
this.uicons = await Promise.all(
diff --git a/src/services/Icons.js b/src/services/Icons.js
index a76df2d09..33393e799 100644
--- a/src/services/Icons.js
+++ b/src/services/Icons.js
@@ -21,8 +21,6 @@ export default class UIcons {
}
build(icons) {
- const baseUrl =
- 'https://raw.githubusercontent.com/WatWowMap/wwm-uicons/main/'
icons.forEach((icon) => {
try {
const { data, name: unclean, path } = icon
@@ -70,7 +68,7 @@ export default class UIcons {
...this[name].modifiers[category],
}
}
- if (path === baseUrl) {
+ if (path.includes('wwm')) {
this.selected.misc = name
}
if (!this.selected[category]) {
@@ -85,6 +83,8 @@ export default class UIcons {
console.error('Issue loading', icon, '\n', e)
}
})
+ // for debugging purposes/viewing
+ window.uicons = this
}
get selection() {
@@ -98,14 +98,14 @@ export default class UIcons {
setSelection(categories, value) {
if (typeof categories === 'object') {
Object.keys(categories).forEach((category) => {
- if (category !== 'misc') {
+ if (this[categories[category]]) {
this.selected[category] = categories[category]
this.modifiers[category] = this[categories[category]]
? this[categories[category]].modifiers[category]
: this.modifiers.base
}
})
- } else if (categories !== 'misc') {
+ } else if (this[categories]) {
this.selected[categories] = value
this.modifiers[categories] = this[value]
? this[value].modifiers[categories]
From 720efb9ed3eba9e3e4592334d705aa2acf8c15cb Mon Sep 17 00:00:00 2001
From: Derick M <58572875+TurtIeSocks@users.noreply.github.com>
Date: Fri, 27 Jan 2023 13:47:30 -0500
Subject: [PATCH 22/23] more uicons
- Freeze objects we don't want to be changeable
- fallback when parsing questRewardTypes from localStorage
---
src/components/Config.jsx | 2 +-
src/services/Icons.js | 28 +++++++++++++++++++++++++++-
2 files changed, 28 insertions(+), 2 deletions(-)
diff --git a/src/components/Config.jsx b/src/components/Config.jsx
index 98bdf7fb0..859efe509 100644
--- a/src/components/Config.jsx
+++ b/src/components/Config.jsx
@@ -34,7 +34,7 @@ export default function Config() {
data.config.icons,
data.masterfile
? data.masterfile.questRewardTypes
- : JSON.parse(localStorage.getItem('questRewardTypes')),
+ : JSON.parse(localStorage.getItem('questRewardTypes') || '{}'),
)
if (Icons) {
Icons.build(data.config.icons.styles)
diff --git a/src/services/Icons.js b/src/services/Icons.js
index 33393e799..b60333b21 100644
--- a/src/services/Icons.js
+++ b/src/services/Icons.js
@@ -1,3 +1,20 @@
+const freezeProps = (target, property) => {
+ const {
+ value,
+ get = () => value,
+ set = () => undefined,
+ // eslint-disable-next-line no-unused-vars
+ writable: _writable,
+ ...desc
+ } = Object.getOwnPropertyDescriptor(target, property)
+ Object.defineProperty(target, property, {
+ ...desc,
+ get,
+ set,
+ configurable: false,
+ })
+}
+
export default class UIcons {
constructor({ customizable, sizes, cacheHrs }, questRewardTypes) {
this.customizable = customizable
@@ -18,6 +35,10 @@ export default class UIcons {
([id, category]) =>
(this.questRewardTypes[id] = category.toLowerCase().replace(' ', '_')),
)
+ // Freezing since we don't change them in the codebase but we're exposing uicons to the global object and we don't want them to be changed in the browser console
+ freezeProps(this, 'customizable')
+ freezeProps(this, 'sizes')
+ freezeProps(this, 'questRewardTypes')
}
build(icons) {
@@ -84,7 +105,12 @@ export default class UIcons {
}
})
// for debugging purposes/viewing
- window.uicons = this
+ Object.defineProperty(window, 'uicons', {
+ value: this,
+ writable: false,
+ enumerable: true,
+ configurable: false,
+ })
}
get selection() {
From 8e8d03bcfd816c174d609eac9c4f22a3de15f1a2 Mon Sep 17 00:00:00 2001
From: Derick M <58572875+TurtIeSocks@users.noreply.github.com>
Date: Sat, 28 Jan 2023 10:39:39 -0500
Subject: [PATCH 23/23] Update Pokestop.js
---
server/src/models/Pokestop.js | 5 ++++-
1 file changed, 4 insertions(+), 1 deletion(-)
diff --git a/server/src/models/Pokestop.js b/server/src/models/Pokestop.js
index e04c45fac..935f09fc0 100644
--- a/server/src/models/Pokestop.js
+++ b/server/src/models/Pokestop.js
@@ -799,7 +799,10 @@ module.exports = class Pokestop extends Model {
}
if (
typeof invasion.grunt_type === 'number' &&
- invasion.incident_expire_timestamp >= ts
+ invasion.incident_expire_timestamp >= ts &&
+ !filtered[result.id].invasions.find(
+ (q) => q.grunt_type === invasion.grunt_type,
+ )
) {
filtered[result.id].invasions.push(invasion)
}