Skip to content

Commit

Permalink
Merge pull request #1071 from ReuschelCGN/max-battle-fix
Browse files Browse the repository at this point in the history
fix: station and maxbattles display due to changes on it
  • Loading branch information
Mygod authored Nov 18, 2024
2 parents 43fe566 + 11531c7 commit e71f9c2
Show file tree
Hide file tree
Showing 9 changed files with 177 additions and 63 deletions.
2 changes: 1 addition & 1 deletion config/default.json
Original file line number Diff line number Diff line change
Expand Up @@ -116,7 +116,7 @@
},
"portalUpdateLimit": 30,
"weatherCellLimit": 3,
"stationUpdateLimit": 30,
"stationUpdateLimit": 6,
"searchResultsLimit": 15,
"searchSoftKmLimit": 10,
"searchHardKmLimit": 100,
Expand Down
25 changes: 17 additions & 8 deletions packages/locales/lib/human/de.json
Original file line number Diff line number Diff line change
Expand Up @@ -165,9 +165,9 @@
"clustering": "Clustering",
"glow": "Glow",
"legacy_filter": "Legacy Filter",
"raid_timers": "Alle Raid Timer",
"invasion_timers": "Alle Invasion Timer",
"lure_timers": "Alle Lockmodul Timer",
"raid_timers": "Raid Timer",
"invasion_timers": "Invasion Timer",
"lure_timers": "Lockmodul Timer",
"device_path_color": "Geräte Pfadfarbe",
"old_portals": "Alte Portale",
"new_portals": "Neue Portale",
Expand Down Expand Up @@ -300,7 +300,7 @@
"weather_icons": "Wetter Icons",
"misc_icons": "Misc Icons",
"invasion_icons": "Invasion Icons",
"pokemon_timers": "Alle Pokemon Timer",
"pokemon_timers": "Pokemon Timer",
"dialog_filter_footer_apply_to_all_width": 2,
"dialog_filter_footer_adv_menu_width": 2,
"dialog_filter_footer_disable_all_width": 2,
Expand Down Expand Up @@ -669,6 +669,7 @@
"done": "Erledigt",
"fast": "Sofort",
"charged": "Lade",
"cooldown": "Cooldown",
"offline_mode": "offline Modus",
"include_sponsored": "einschließlich gesponserte",
"showcase_color": "Showcasefarbe",
Expand Down Expand Up @@ -782,11 +783,19 @@
"dynamax": "Dynamax",
"stations_subtitle": "Kraftquellen auf der Map anzeigen",
"dynamax_subtitle": "Dyna-Raids auf der Map anzeigen",
"override": "Dyna-Raid Override",
"override": "Dyna Override",
"station_icons": "Kraftquellen Icons",
"stationed_pokemon": "platzierte Pokémon",
"placed_pokemon": "platzierte Pokémon",
"attack_bonus": "Angriffsbonus",
"no_stationed_pokemon": "Keine Pokémon platziert",
"battle_bonus": "Kampfbonus",
"copy_coordinates": "Koordinaten kopieren"
"copy_coordinates": "Koordinaten kopieren",
"enable_station_popup_coords": "Kraftquellen Koordinaten anzeigen",
"station_icons": "Kraftquellen Icons",
"dynamic_opacity": "dynamische Durchsichtigkeit",
"tooltips": "Tooltips",
"markers": "Marker",
"filters": "Filter",
"active": "aktiv",
"inactive": "inaktiv",
"bread_time_window": "Du kannst von 6Uhr bis 21Uhr an Dyna-Kämpfen teilnehmen."
}
7 changes: 5 additions & 2 deletions packages/locales/lib/human/en.json
Original file line number Diff line number Diff line change
Expand Up @@ -815,5 +815,8 @@
"dynamic_opacity": "Dynamic Opacity",
"tooltips": "Tooltips",
"markers": "Markers",
"filters": "Filters"
}
"filters": "Filters",
"active": "Active",
"inactive": "Inactive",
"bread_time_window": "You can take on Max Battles between 6AM and 9PM."
}
5 changes: 3 additions & 2 deletions packages/locales/lib/human/es.json
Original file line number Diff line number Diff line change
Expand Up @@ -617,5 +617,6 @@
"show_editor": "Mostrar Editor",
"hide_editor": "Ocultar Editor",
"reported_error": "Este error ha sido reportado al servidor con el identificador",
"dark_mode": "Modo Oscuro"
}
"dark_mode": "Modo Oscuro",
"bread_time_window": "Puedes acceder a los Combates Max de 6h a 21h."
}
7 changes: 5 additions & 2 deletions packages/locales/lib/human/fr.json
Original file line number Diff line number Diff line change
Expand Up @@ -771,5 +771,8 @@
"spawnpoint_audio": "Son de point d’apparition",
"team_audio": "Son d’équipe",
"type_audio": "Son de type",
"weather_audio": "Son de météo"
}
"weather_audio": "Son de météo",
"active": "Actif",
"inactive": "Inactif",
"bread_time_window": "Tu peux participer à des Combats Dynamax entre 6h et 21h."
}
15 changes: 13 additions & 2 deletions server/src/models/Station.js
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ class Station extends Model {
*/
static async getAll(perms, args, { isMad }) {
const { areaRestrictions } = perms
const { stationUpdateLimit } = config.getSafe('api')
const { onlyAreas, onlyAllStations, onlyMaxBattles, onlyBattleTier } =
args.filters
const ts = getEpoch()
Expand All @@ -40,6 +41,11 @@ class Station extends Model {
.whereBetween('lat', [args.minLat, args.maxLat])
.andWhereBetween('lon', [args.minLon, args.maxLon])
.andWhere('end_time', '>', ts)
.andWhere(
'updated',
'>',
Date.now() / 1000 - stationUpdateLimit * 60 * 60,
)
// .where('is_inactive', false)

if (perms.dynamax && onlyMaxBattles) {
Expand Down Expand Up @@ -161,10 +167,16 @@ class Station extends Model {
static async getAvailable() {
/** @type {import('@rm/types').FullStation[]} */
const ts = getEpoch()
const { stationUpdateLimit } = config.getSafe('api')
const results = await this.query()
.distinct(['battle_pokemon_id', 'battle_pokemon_form', 'battle_level'])
.where('is_inactive', false)
.andWhere('battle_end', '>', ts)
.andWhere(
'updated',
'>',
Date.now() / 1000 - stationUpdateLimit * 60 * 60,
)
.groupBy(['battle_pokemon_id', 'battle_pokemon_form', 'battle_level'])
.orderBy('battle_pokemon_id', 'asc')
return {
Expand Down Expand Up @@ -224,7 +236,7 @@ class Station extends Model {
.andWhere(
'updated',
'>',
Date.now() / 1000 - stationUpdateLimit * 60 * 60 * 24,
Date.now() / 1000 - stationUpdateLimit * 60 * 60,
)
.andWhere('end_time', '>', ts)
.andWhere((builder) => {
Expand All @@ -235,7 +247,6 @@ class Station extends Model {
builder.orWhere((builder2) => {
builder2
.whereIn('battle_pokemon_id', pokemonIds)
.andWhere('is_battle_available', true)
.andWhere('battle_end', '>', ts)
})
}
Expand Down
Loading

0 comments on commit e71f9c2

Please sign in to comment.