Skip to content

Commit bd37100

Browse files
committed
fix: add expire to raid battle and pokemon search
1 parent 9cd2be5 commit bd37100

File tree

6 files changed

+17
-6
lines changed

6 files changed

+17
-6
lines changed

server/src/graphql/typeDefs/map.graphql

+3
Original file line numberDiff line numberDiff line change
@@ -64,19 +64,22 @@ type Search {
6464
raid_pokemon_costume: Int
6565
raid_pokemon_evolution: Int
6666
raid_pokemon_alignment: Int
67+
raid_end_timestamp: Int
6768
pokemon_id: Int
6869
form: Int
6970
gender: Int
7071
costume: Int
7172
shiny: Int
7273
iv: Float
74+
expire_timestamp: Int
7375
battle_pokemon_id: Int
7476
battle_pokemon_form: Int
7577
battle_pokemon_gender: Int
7678
battle_pokemon_costume: Int
7779
# battle_pokemon_evolution: Int
7880
battle_pokemon_alignment: Int
7981
battle_pokemon_bread_mode: Int
82+
battle_end: Int
8083
}
8184

8285
type SearchLure {

server/src/models/Gym.js

+2-5
Original file line numberDiff line numberDiff line change
@@ -528,6 +528,7 @@ class Gym extends Model {
528528
isMad
529529
? 'evolution AS raid_pokemon_evolution'
530530
: 'raid_pokemon_evolution',
531+
isMad ? 'end AS raid_end_timestamp' : 'raid_end_timestamp',
531532
distance,
532533
])
533534
.whereBetween(isMad ? 'latitude' : 'lat', [bbox.minLat, bbox.maxLat])
@@ -536,11 +537,7 @@ class Gym extends Model {
536537
.limit(config.getSafe('api.searchResultsLimit'))
537538
.orderBy('distance')
538539
.andWhere('raid_pokemon_id', '>', 0)
539-
.andWhere(
540-
isMad ? 'end' : 'raid_end_timestamp',
541-
'>=',
542-
isMad ? this.knex().fn.now() : ts,
543-
)
540+
.andWhere('raid_end_timestamp', '>=', isMad ? this.knex().fn.now() : ts)
544541
if (isMad) {
545542
query
546543
.leftJoin('gymdetails', 'gym.gym_id', 'gymdetails.gym_id')

server/src/models/Pokemon.js

+2
Original file line numberDiff line numberDiff line change
@@ -617,6 +617,7 @@ class Pokemon extends Model {
617617
'gender',
618618
'costume',
619619
raw(IV_CALC).as('iv'),
620+
'disappear_time AS expire_timestamp',
620621
])
621622
} else {
622623
query.select([
@@ -628,6 +629,7 @@ class Pokemon extends Model {
628629
'gender',
629630
'iv',
630631
'shiny',
632+
'expire_timestamp',
631633
])
632634
}
633635
if (!getAreaSql(query, perms.areaRestrictions, onlyAreas, isMad)) {

server/src/models/Station.js

+1
Original file line numberDiff line numberDiff line change
@@ -254,6 +254,7 @@ class Station extends Model {
254254
'battle_pokemon_gender',
255255
'battle_pokemon_alignment',
256256
'battle_pokemon_bread_mode',
257+
'battle_end',
257258
)
258259
}
259260

src/features/search/renderOption.jsx

+6
Original file line numberDiff line numberDiff line change
@@ -162,6 +162,12 @@ export const renderOption = ({ key, ...props }, option) => {
162162
<Timer expireTime={option.incident_expire_timestamp} />
163163
) : searchTab === 'lures' ? (
164164
<Timer expireTime={option.lure_expire_timestamp} />
165+
) : searchTab === 'raids' ? (
166+
<Timer expireTime={option.raid_end_timestamp} />
167+
) : searchTab === 'pokemon' ? (
168+
<Timer expireTime={option.expire_timestamp} />
169+
) : searchTab === 'stations' ? (
170+
<Timer expireTime={option.battle_end} />
165171
) : (
166172
''
167173
)

src/services/queries/search.js

+3-1
Original file line numberDiff line numberDiff line change
@@ -133,12 +133,12 @@ export const POKEMON = gql`
133133
) {
134134
...CoreSearch
135135
pokemon_id
136-
pokemon_id
137136
form
138137
gender
139138
costume
140139
shiny
141140
iv
141+
expire_timestamp
142142
}
143143
}
144144
`
@@ -213,6 +213,7 @@ export const RAIDS = gql`
213213
raid_pokemon_costume
214214
raid_pokemon_evolution
215215
raid_pokemon_alignment
216+
raid_end_timestamp
216217
}
217218
}
218219
`
@@ -278,6 +279,7 @@ export const MAX_BATTLES = gql`
278279
# battle_pokemon_evolution
279280
battle_pokemon_alignment
280281
battle_pokemon_bread_mode
282+
battle_end
281283
}
282284
}
283285
`

0 commit comments

Comments
 (0)