Skip to content

Commit cf1ca1c

Browse files
authoredOct 3, 2024··
Merge pull request WatWowMap#1065 from ReuschelCGN/develop-expired-stations
fix: display only available stations / dynaraids
2 parents 623fa62 + b8effb9 commit cf1ca1c

File tree

1 file changed

+6
-0
lines changed

1 file changed

+6
-0
lines changed
 

‎server/src/models/Station.js

+6
Original file line numberDiff line numberDiff line change
@@ -62,6 +62,7 @@ class Station extends Model {
6262
query
6363
.whereNotNull('battle_pokemon_id')
6464
.andWhere('is_battle_available', true)
65+
.andWhere('battle_end', '>', ts)
6566

6667
if (onlyBattleTier === 'all') {
6768
const battleBosses = new Set()
@@ -159,9 +160,11 @@ class Station extends Model {
159160

160161
static async getAvailable() {
161162
/** @type {import('@rm/types').FullStation[]} */
163+
const ts = getEpoch()
162164
const results = await this.query()
163165
.distinct(['battle_pokemon_id', 'battle_pokemon_form', 'battle_level'])
164166
.where('is_inactive', false)
167+
.andWhere('end_time', '>', ts)
165168
.groupBy(['battle_pokemon_id', 'battle_pokemon_form', 'battle_level'])
166169
.orderBy('battle_pokemon_id', 'asc')
167170
return {
@@ -191,6 +194,7 @@ class Station extends Model {
191194
const { areaRestrictions } = perms
192195
const { onlyAreas = [], search = '', locale } = args
193196
const { searchResultsLimit, stationUpdateLimit } = config.getSafe('api')
197+
const ts = getEpoch()
194198

195199
const pokemonIds = Object.keys(state.event.masterfile.pokemon).filter(
196200
(pkmn) =>
@@ -222,6 +226,7 @@ class Station extends Model {
222226
'>',
223227
Date.now() / 1000 - stationUpdateLimit * 60 * 60 * 24,
224228
)
229+
.andWhere('end_time', '>', ts)
225230
.andWhere((builder) => {
226231
if (perms.stations) {
227232
builder.orWhereILike('name', `%${search}%`)
@@ -231,6 +236,7 @@ class Station extends Model {
231236
builder2
232237
.whereIn('battle_pokemon_id', pokemonIds)
233238
.andWhere('is_battle_available', true)
239+
.andWhere('battle_end', '>', ts)
234240
})
235241
}
236242
})

0 commit comments

Comments
 (0)
Please sign in to comment.