Skip to content

Commit

Permalink
updated current weather in gym properties
Browse files Browse the repository at this point in the history
  • Loading branch information
Pontiky committed Mar 11, 2022
1 parent 64bc2a6 commit 4f81046
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 7 deletions.
22 changes: 16 additions & 6 deletions mapadroid/db/DbPogoProtoSubmit.py
Original file line number Diff line number Diff line change
Expand Up @@ -746,15 +746,15 @@ def gyms(self, origin: str, map_proto: dict):

query_gym = (
"INSERT INTO gym (gym_id, team_id, guard_pokemon_id, slots_available, enabled, latitude, longitude, "
"total_cp, is_in_battle, last_modified, last_scanned, is_ex_raid_eligible, is_ar_scan_eligible) "
"VALUES (%s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s) "
"total_cp, is_in_battle, last_modified, last_scanned, is_ex_raid_eligible, is_ar_scan_eligible, "
"weather_boosted_condition) "
"VALUES (%s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s) "
"ON DUPLICATE KEY UPDATE "
"guard_pokemon_id=VALUES(guard_pokemon_id), team_id=VALUES(team_id), "
"slots_available=VALUES(slots_available), last_scanned=VALUES(last_scanned), "
"last_modified=VALUES(last_modified), latitude=VALUES(latitude), longitude=VALUES(longitude), "
"is_ex_raid_eligible=VALUES(is_ex_raid_eligible),"
"is_ar_scan_eligible=VALUES(is_ar_scan_eligible),"
"is_in_battle=VALUES(is_in_battle)"
"is_ex_raid_eligible=VALUES(is_ex_raid_eligible), is_ar_scan_eligible=VALUES(is_ar_scan_eligible), "
"is_in_battle=VALUES(is_in_battle), weather_boosted_condition=VALUES(weather_boosted_condition)"
)
query_gym_details = (
"INSERT INTO gymdetails (gym_id, name, url, last_scanned) "
Expand All @@ -778,6 +778,15 @@ def gyms(self, origin: str, map_proto: dict):
is_ex_raid_eligible = gym["gym_details"]["is_ex_raid_eligible"]
is_ar_scan_eligible = gym["is_ar_scan_eligible"]
is_in_battle = gym['gym_details']['is_in_battle']
s2_cell_id = S2Helper.lat_lng_to_cell_id(latitude, longitude)
sql = "SELECT `gameplay_weather` " \
"FROM weather " \
"WHERE s2_cell_id = {}".format(s2_cell_id)
found = self._db_exec.execute(sql)
if len(found) == 1:
weather_id = found[0][0]
else:
weather_id = 0 # unknown

cache_key = "gym{}{}".format(gymid, last_modified_ts)
if cache.exists(cache_key):
Expand All @@ -793,7 +802,8 @@ def gyms(self, origin: str, map_proto: dict):
last_modified, # last_modified
now, # last_scanned
is_ex_raid_eligible,
is_ar_scan_eligible
is_ar_scan_eligible,
weather_id # weather_boosted_condition
)
)

Expand Down
2 changes: 1 addition & 1 deletion mapadroid/db/DbWebhookReader.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ def get_raids_changed_since(self, timestamp):
"SELECT raid.gym_id, raid.level, raid.spawn, raid.start, raid.end, raid.pokemon_id, "
"raid.cp, raid.move_1, raid.move_2, raid.last_scanned, raid.form, raid.is_exclusive, raid.gender, "
"raid.costume, raid.evolution, gymdetails.name, gymdetails.url, gym.latitude, gym.longitude, "
"gym.team_id, weather_boosted_condition, gym.is_ex_raid_eligible "
"gym.team_id, gym.weather_boosted_condition, gym.is_ex_raid_eligible "
"FROM raid "
"LEFT JOIN gymdetails ON gymdetails.gym_id = raid.gym_id "
"LEFT JOIN gym ON gym.gym_id = raid.gym_id "
Expand Down

0 comments on commit 4f81046

Please sign in to comment.