From 4b73c2738aef458dbf934655b238a309025e1706 Mon Sep 17 00:00:00 2001 From: Jeff Date: Wed, 19 Jun 2024 09:30:18 -0700 Subject: [PATCH 1/9] Add front end toggles --- src/features/drawer/pokestops/Invasions.jsx | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/src/features/drawer/pokestops/Invasions.jsx b/src/features/drawer/pokestops/Invasions.jsx index 112a3781f..266982eae 100644 --- a/src/features/drawer/pokestops/Invasions.jsx +++ b/src/features/drawer/pokestops/Invasions.jsx @@ -24,6 +24,16 @@ const BaseInvasion = () => { label="only_confirmed" /> )} + + {confirmedEnabled || hasConfirmed ? ( Date: Wed, 19 Jun 2024 09:31:04 -0700 Subject: [PATCH 2/9] Add grunt & leader filter along with some defaults --- server/src/configs/custom-environment-variables.json | 8 ++++++++ server/src/configs/default.json | 2 ++ server/src/services/filters/builder/base.js | 6 ++++++ 3 files changed, 16 insertions(+) diff --git a/server/src/configs/custom-environment-variables.json b/server/src/configs/custom-environment-variables.json index 6d28900c4..e29d81068 100644 --- a/server/src/configs/custom-environment-variables.json +++ b/server/src/configs/custom-environment-variables.json @@ -989,6 +989,14 @@ "__name": "DEFAULT_FILTERS_POKESTOPS_CONFIRMED", "__format": "boolean" }, + "excludeGrunts": { + "__name": "DEFAULT_FILTERS_POKESTOPS_EXCLUDE_GRUNTS", + "__format": "boolean" + }, + "excludeLeaders": { + "__name": "DEFAULT_FILTERS_POKESTOPS_EXCLUDE_LEADERS", + "__format": "boolean" + }, "items": { "__name": "DEFAULT_FILTERS_POKESTOPS_ITEMS", "__format": "boolean" diff --git a/server/src/configs/default.json b/server/src/configs/default.json index 0e3524d38..0f33528f6 100644 --- a/server/src/configs/default.json +++ b/server/src/configs/default.json @@ -482,6 +482,8 @@ "showcasePokemon": true, "questSet": "both", "confirmed": false, + "excludeGrunts": false, + "excludeLeaders": false, "items": true, "megaEnergy": true, "candy": true, diff --git a/server/src/services/filters/builder/base.js b/server/src/services/filters/builder/base.js index 119f8f9e3..5e9f7e19d 100644 --- a/server/src/services/filters/builder/base.js +++ b/server/src/services/filters/builder/base.js @@ -91,6 +91,12 @@ function buildDefaultFilters(perms) { confirmed: perms.invasions ? defaultFilters.pokestops.confirmed : undefined, + excludeGrunts: perms.invasions + ? defaultFilters.pokestops.excludeGrunts + : undefined, + excludeLeaders: perms.invasions + ? defaultFilters.pokestops.excludeLeaders + : undefined, invasions: perms.invasions ? defaultFilters.pokestops.invasions : undefined, From 6e9adc0763a56b478fe0db09b249718257b681af Mon Sep 17 00:00:00 2001 From: Jeff Date: Wed, 19 Jun 2024 09:34:37 -0700 Subject: [PATCH 3/9] add back end support for the rocket filters --- server/src/models/Pokestop.js | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) diff --git a/server/src/models/Pokestop.js b/server/src/models/Pokestop.js index 43d9fc99c..0a3352674 100644 --- a/server/src/models/Pokestop.js +++ b/server/src/models/Pokestop.js @@ -135,11 +135,16 @@ class Pokestop extends Model { onlyEventStops, onlyConfirmed, onlyAreas = [], + onlyExcludeGrunts, + onlyExcludeLeaders, }, } = args const midnight = getUserMidnight(args) const ts = Math.floor(Date.now() / 1000) + const rocketGruntIDs = [4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25,26,27,28,29,30,31,32,33,34,35,36,37,38,39,47,48,49,50] + const rocketLeaderIDs = [41, 42, 43, 44] + const { lures: lurePerms, quests: questPerms, @@ -573,6 +578,13 @@ class Pokestop extends Model { ) } }) + if (onlyExcludeGrunts) { + invasion.whereNotIn('character', rocketGruntIDs) + } + + if (onlyExcludeLeaders) { + invasion.whereNotIn('character', rocketLeaderIDs) + } }) } else { stops.orWhere((invasion) => { @@ -592,6 +604,13 @@ class Pokestop extends Model { if (hasConfirmed) { invasion.andWhere('confirmed', onlyConfirmed) } + if (onlyExcludeGrunts) { + invasion.whereNotIn('character', rocketGruntIDs) + } + + if (onlyExcludeLeaders) { + invasion.whereNotIn('character', rocketLeaderIDs) + } }) } } From 0982efac0cb0e7b6d02229bb9a84ff26d50326c2 Mon Sep 17 00:00:00 2001 From: Jeff Date: Wed, 19 Jun 2024 09:34:48 -0700 Subject: [PATCH 4/9] add some translations --- packages/locales/lib/human/de.json | 4 +++- packages/locales/lib/human/en.json | 4 +++- packages/locales/lib/human/es.json | 4 +++- packages/locales/lib/human/fr.json | 4 +++- packages/locales/lib/human/pl.json | 4 +++- 5 files changed, 15 insertions(+), 5 deletions(-) diff --git a/packages/locales/lib/human/de.json b/packages/locales/lib/human/de.json index 4c7112bbb..4e0691482 100644 --- a/packages/locales/lib/human/de.json +++ b/packages/locales/lib/human/de.json @@ -585,6 +585,8 @@ "delete": "löschen", "name": "Name", "only_confirmed": "nur bestätigte", + "only_exclude_grunts": "Grunzer ausschließen", + "only_exclude_leaders": "EAnführer ausschließen", "rocket_pokemon": "Crypto-Pokemon", "decoy": "Täusch-Rüpel", "s2_cell_limit_0": "Sie haben versucht, mehr als 20.000 Zellen zu generieren ({{variable_0}})", @@ -759,4 +761,4 @@ "locale_instructions_8": "Warte bis die Pull-Anfrage überprüft und gemerged wurde.", "enter_translation": "Übersetzung eingeben", "individual_filters": "Teilweise gefiltert" -} +} \ No newline at end of file diff --git a/packages/locales/lib/human/en.json b/packages/locales/lib/human/en.json index 574a341d9..c9ec7bb35 100644 --- a/packages/locales/lib/human/en.json +++ b/packages/locales/lib/human/en.json @@ -615,6 +615,8 @@ "delete": "Delete", "name": "Name", "only_confirmed": "Only Confirmed", + "only_exclude_grunts": "Exclude Grunts", + "only_exclude_leaders": "Exclude Leaders", "rocket_pokemon": "Rocket Pokémon", "decoy": "Decoy", "s2_cell_limit_0": "You attempted to generate more than 20,000 cells ({{variable_0}})", @@ -783,4 +785,4 @@ "locale_instructions_8": "Wait for the pull request to be reviewed and merged", "enter_translation": "Enter Translation", "individual_filters": "Partially Filtered" -} +} \ No newline at end of file diff --git a/packages/locales/lib/human/es.json b/packages/locales/lib/human/es.json index 26528d5a6..50d0a5cc5 100644 --- a/packages/locales/lib/human/es.json +++ b/packages/locales/lib/human/es.json @@ -544,6 +544,8 @@ "delete": "Eliminar", "name": "Nombre", "only_confirmed": "Solo confirmados", + "only_exclude_grunts": "Excluir gruñidos", + "only_exclude_leaders": "Excluir a los dirigentes", "rocket_pokemon": "Pokémon del Equipo Rocket", "decoy": "Señuelo", "s2_cell_limit_0": "Has intentado generar más de 20,000 celdas ({{variable_0}})", @@ -616,4 +618,4 @@ "hide_editor": "Ocultar Editor", "reported_error": "Este error ha sido reportado al servidor con el identificador", "dark_mode": "Modo Oscuro" -} +} \ No newline at end of file diff --git a/packages/locales/lib/human/fr.json b/packages/locales/lib/human/fr.json index 10d01fc57..a82758045 100644 --- a/packages/locales/lib/human/fr.json +++ b/packages/locales/lib/human/fr.json @@ -571,6 +571,8 @@ "delete": "Supprimer", "name": "Nom", "only_confirmed": "Confirmé seulement", + "only_exclude_grunts": "Exclure les grognements", + "only_exclude_leaders": "Exclure les dirigeants", "rocket_pokemon": "Pokémon Rocket", "decoy": "Leurre", "s2_cell_limit_0": "Vous avez essayé de générer plus de 20 000 cellules ({{variable_0}})", @@ -770,4 +772,4 @@ "team_audio": "Son d’équipe", "type_audio": "Son de type", "weather_audio": "Son de météo" -} +} \ No newline at end of file diff --git a/packages/locales/lib/human/pl.json b/packages/locales/lib/human/pl.json index fba7266ce..dd3de4e90 100644 --- a/packages/locales/lib/human/pl.json +++ b/packages/locales/lib/human/pl.json @@ -395,6 +395,8 @@ "online": "Online", "only_available": "Dostępne", "only_confirmed": "Tylko potwierdzone", + "only_exclude_grunts": "Wykluczyć chrząknięcia", + "only_exclude_leaders": "Wykluczyć liderów", "only_global": "Tylko globalne", "only_show_available": "Pokaż tylko dostępne", "opacity_five_minutes": "Przezroczystość po 5 minutach", @@ -767,4 +769,4 @@ "zero_iv": "0% IV", "zoom_in": "Przybliż", "zoom_out": "Oddal" -} +} \ No newline at end of file From 9efc12fcc95dc8cf88e8602fb73f662d6a25e248 Mon Sep 17 00:00:00 2001 From: Jeff Date: Wed, 19 Jun 2024 09:52:21 -0700 Subject: [PATCH 5/9] add backwards compatability with map-a-droid --- server/src/models/Pokestop.js | 20 ++++++++++++++++---- 1 file changed, 16 insertions(+), 4 deletions(-) diff --git a/server/src/models/Pokestop.js b/server/src/models/Pokestop.js index 0a3352674..9a577b5bc 100644 --- a/server/src/models/Pokestop.js +++ b/server/src/models/Pokestop.js @@ -579,11 +579,17 @@ class Pokestop extends Model { } }) if (onlyExcludeGrunts) { - invasion.whereNotIn('character', rocketGruntIDs) + invasion.whereNotIn( + isMad ? 'character_display' : 'character', + rocketGruntIDs + ) } if (onlyExcludeLeaders) { - invasion.whereNotIn('character', rocketLeaderIDs) + invasion.whereNotIn( + isMad ? 'character_display' : 'character', + rocketLeaderIDs + ) } }) } else { @@ -605,11 +611,17 @@ class Pokestop extends Model { invasion.andWhere('confirmed', onlyConfirmed) } if (onlyExcludeGrunts) { - invasion.whereNotIn('character', rocketGruntIDs) + invasion.whereNotIn( + isMad ? 'character_display' : 'character', + rocketGruntIDs + ) } if (onlyExcludeLeaders) { - invasion.whereNotIn('character', rocketLeaderIDs) + invasion.whereNotIn( + isMad ? 'character_display' : 'character', + rocketLeaderIDs + ) } }) } From 75263bec654731546ed438d2205027c1a8dab346 Mon Sep 17 00:00:00 2001 From: Jeff Date: Wed, 19 Jun 2024 09:55:37 -0700 Subject: [PATCH 6/9] removing translations --- packages/locales/lib/human/de.json | 2 -- packages/locales/lib/human/es.json | 2 -- packages/locales/lib/human/fr.json | 2 -- packages/locales/lib/human/pl.json | 2 -- 4 files changed, 8 deletions(-) diff --git a/packages/locales/lib/human/de.json b/packages/locales/lib/human/de.json index 4e0691482..cbaff59fe 100644 --- a/packages/locales/lib/human/de.json +++ b/packages/locales/lib/human/de.json @@ -585,8 +585,6 @@ "delete": "löschen", "name": "Name", "only_confirmed": "nur bestätigte", - "only_exclude_grunts": "Grunzer ausschließen", - "only_exclude_leaders": "EAnführer ausschließen", "rocket_pokemon": "Crypto-Pokemon", "decoy": "Täusch-Rüpel", "s2_cell_limit_0": "Sie haben versucht, mehr als 20.000 Zellen zu generieren ({{variable_0}})", diff --git a/packages/locales/lib/human/es.json b/packages/locales/lib/human/es.json index 50d0a5cc5..92bb6d687 100644 --- a/packages/locales/lib/human/es.json +++ b/packages/locales/lib/human/es.json @@ -544,8 +544,6 @@ "delete": "Eliminar", "name": "Nombre", "only_confirmed": "Solo confirmados", - "only_exclude_grunts": "Excluir gruñidos", - "only_exclude_leaders": "Excluir a los dirigentes", "rocket_pokemon": "Pokémon del Equipo Rocket", "decoy": "Señuelo", "s2_cell_limit_0": "Has intentado generar más de 20,000 celdas ({{variable_0}})", diff --git a/packages/locales/lib/human/fr.json b/packages/locales/lib/human/fr.json index a82758045..6a9d948ea 100644 --- a/packages/locales/lib/human/fr.json +++ b/packages/locales/lib/human/fr.json @@ -571,8 +571,6 @@ "delete": "Supprimer", "name": "Nom", "only_confirmed": "Confirmé seulement", - "only_exclude_grunts": "Exclure les grognements", - "only_exclude_leaders": "Exclure les dirigeants", "rocket_pokemon": "Pokémon Rocket", "decoy": "Leurre", "s2_cell_limit_0": "Vous avez essayé de générer plus de 20 000 cellules ({{variable_0}})", diff --git a/packages/locales/lib/human/pl.json b/packages/locales/lib/human/pl.json index dd3de4e90..e0933e012 100644 --- a/packages/locales/lib/human/pl.json +++ b/packages/locales/lib/human/pl.json @@ -395,8 +395,6 @@ "online": "Online", "only_available": "Dostępne", "only_confirmed": "Tylko potwierdzone", - "only_exclude_grunts": "Wykluczyć chrząknięcia", - "only_exclude_leaders": "Wykluczyć liderów", "only_global": "Tylko globalne", "only_show_available": "Pokaż tylko dostępne", "opacity_five_minutes": "Przezroczystość po 5 minutach", From b193b37772dd97bfe6d7696aa1edb01074bc3216 Mon Sep 17 00:00:00 2001 From: Jeff Date: Wed, 19 Jun 2024 09:58:13 -0700 Subject: [PATCH 7/9] re-including translations --- packages/locales/lib/human/de.json | 2 ++ packages/locales/lib/human/es.json | 2 ++ packages/locales/lib/human/fr.json | 2 ++ packages/locales/lib/human/pl.json | 2 ++ 4 files changed, 8 insertions(+) diff --git a/packages/locales/lib/human/de.json b/packages/locales/lib/human/de.json index cbaff59fe..4e0691482 100644 --- a/packages/locales/lib/human/de.json +++ b/packages/locales/lib/human/de.json @@ -585,6 +585,8 @@ "delete": "löschen", "name": "Name", "only_confirmed": "nur bestätigte", + "only_exclude_grunts": "Grunzer ausschließen", + "only_exclude_leaders": "EAnführer ausschließen", "rocket_pokemon": "Crypto-Pokemon", "decoy": "Täusch-Rüpel", "s2_cell_limit_0": "Sie haben versucht, mehr als 20.000 Zellen zu generieren ({{variable_0}})", diff --git a/packages/locales/lib/human/es.json b/packages/locales/lib/human/es.json index 92bb6d687..50d0a5cc5 100644 --- a/packages/locales/lib/human/es.json +++ b/packages/locales/lib/human/es.json @@ -544,6 +544,8 @@ "delete": "Eliminar", "name": "Nombre", "only_confirmed": "Solo confirmados", + "only_exclude_grunts": "Excluir gruñidos", + "only_exclude_leaders": "Excluir a los dirigentes", "rocket_pokemon": "Pokémon del Equipo Rocket", "decoy": "Señuelo", "s2_cell_limit_0": "Has intentado generar más de 20,000 celdas ({{variable_0}})", diff --git a/packages/locales/lib/human/fr.json b/packages/locales/lib/human/fr.json index 6a9d948ea..a82758045 100644 --- a/packages/locales/lib/human/fr.json +++ b/packages/locales/lib/human/fr.json @@ -571,6 +571,8 @@ "delete": "Supprimer", "name": "Nom", "only_confirmed": "Confirmé seulement", + "only_exclude_grunts": "Exclure les grognements", + "only_exclude_leaders": "Exclure les dirigeants", "rocket_pokemon": "Pokémon Rocket", "decoy": "Leurre", "s2_cell_limit_0": "Vous avez essayé de générer plus de 20 000 cellules ({{variable_0}})", diff --git a/packages/locales/lib/human/pl.json b/packages/locales/lib/human/pl.json index e0933e012..dd3de4e90 100644 --- a/packages/locales/lib/human/pl.json +++ b/packages/locales/lib/human/pl.json @@ -395,6 +395,8 @@ "online": "Online", "only_available": "Dostępne", "only_confirmed": "Tylko potwierdzone", + "only_exclude_grunts": "Wykluczyć chrząknięcia", + "only_exclude_leaders": "Wykluczyć liderów", "only_global": "Tylko globalne", "only_show_available": "Pokaż tylko dostępne", "opacity_five_minutes": "Przezroczystość po 5 minutach", From ec35b141f0cf47bb66111c59c2d6e1ad52a2502a Mon Sep 17 00:00:00 2001 From: Jeff Date: Wed, 19 Jun 2024 10:06:18 -0700 Subject: [PATCH 8/9] run prettier on pokestop.js --- server/src/models/Pokestop.js | 18 +++++++++++------- 1 file changed, 11 insertions(+), 7 deletions(-) diff --git a/server/src/models/Pokestop.js b/server/src/models/Pokestop.js index 9a577b5bc..a8ce15100 100644 --- a/server/src/models/Pokestop.js +++ b/server/src/models/Pokestop.js @@ -142,7 +142,11 @@ class Pokestop extends Model { const midnight = getUserMidnight(args) const ts = Math.floor(Date.now() / 1000) - const rocketGruntIDs = [4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25,26,27,28,29,30,31,32,33,34,35,36,37,38,39,47,48,49,50] + const rocketGruntIDs = [ + 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, + 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 47, 48, + 49, 50, + ] const rocketLeaderIDs = [41, 42, 43, 44] const { @@ -581,14 +585,14 @@ class Pokestop extends Model { if (onlyExcludeGrunts) { invasion.whereNotIn( isMad ? 'character_display' : 'character', - rocketGruntIDs + rocketGruntIDs, ) } - + if (onlyExcludeLeaders) { invasion.whereNotIn( isMad ? 'character_display' : 'character', - rocketLeaderIDs + rocketLeaderIDs, ) } }) @@ -613,14 +617,14 @@ class Pokestop extends Model { if (onlyExcludeGrunts) { invasion.whereNotIn( isMad ? 'character_display' : 'character', - rocketGruntIDs + rocketGruntIDs, ) } - + if (onlyExcludeLeaders) { invasion.whereNotIn( isMad ? 'character_display' : 'character', - rocketLeaderIDs + rocketLeaderIDs, ) } }) From 8f851babf6c7448deb4583c233a614bcac84a306 Mon Sep 17 00:00:00 2001 From: Jeff Date: Wed, 19 Jun 2024 18:58:00 -0700 Subject: [PATCH 9/9] Dynamically get grunt IDs from invasions --- server/src/models/Pokestop.js | 24 ++---------------------- server/src/services/EventManager.js | 17 +++++++++++++++++ 2 files changed, 19 insertions(+), 22 deletions(-) diff --git a/server/src/models/Pokestop.js b/server/src/models/Pokestop.js index a8ce15100..a5be7afc2 100644 --- a/server/src/models/Pokestop.js +++ b/server/src/models/Pokestop.js @@ -142,13 +142,6 @@ class Pokestop extends Model { const midnight = getUserMidnight(args) const ts = Math.floor(Date.now() / 1000) - const rocketGruntIDs = [ - 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, - 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 47, 48, - 49, 50, - ] - const rocketLeaderIDs = [41, 42, 43, 44] - const { lures: lurePerms, quests: questPerms, @@ -585,14 +578,14 @@ class Pokestop extends Model { if (onlyExcludeGrunts) { invasion.whereNotIn( isMad ? 'character_display' : 'character', - rocketGruntIDs, + Event.rocketGruntIDs, ) } if (onlyExcludeLeaders) { invasion.whereNotIn( isMad ? 'character_display' : 'character', - rocketLeaderIDs, + Event.rocketLeaderIDs, ) } }) @@ -614,19 +607,6 @@ class Pokestop extends Model { if (hasConfirmed) { invasion.andWhere('confirmed', onlyConfirmed) } - if (onlyExcludeGrunts) { - invasion.whereNotIn( - isMad ? 'character_display' : 'character', - rocketGruntIDs, - ) - } - - if (onlyExcludeLeaders) { - invasion.whereNotIn( - isMad ? 'character_display' : 'character', - rocketLeaderIDs, - ) - } }) } } diff --git a/server/src/services/EventManager.js b/server/src/services/EventManager.js index 598bf678c..e4bb45df7 100644 --- a/server/src/services/EventManager.js +++ b/server/src/services/EventManager.js @@ -325,6 +325,23 @@ class EventManager { try { const newInvasions = await fetch(endpoint).then((res) => res.json()) if (newInvasions) { + this.rocketGruntIDs = Object.keys(newInvasions) + .filter( + (key) => + newInvasions[key].grunt && + newInvasions[key].grunt.includes('Grunt'), + ) + .map(Number) + + this.rocketLeaderIDs = Object.keys(newInvasions) + .filter( + (key) => + newInvasions[key].grunt && + (newInvasions[key].grunt.includes('Executive') || + newInvasions[key].grunt.includes('Giovanni')), + ) + .map(Number) + this.invasions = newInvasions } } catch (e) {