Skip to content

Commit

Permalink
Move stats saving before cache check (#1207)
Browse files Browse the repository at this point in the history
* Move stats saving before cache check

People complain that they liked previous behavior more.

* Update DbPogoProtoSubmit.py

* Update DbPogoProtoSubmit.py

* Stupid github editor, again.
  • Loading branch information
JabLuszko authored Dec 14, 2021
1 parent 80be05c commit 543c3d7
Showing 1 changed file with 3 additions and 5 deletions.
8 changes: 3 additions & 5 deletions mapadroid/db/DbPogoProtoSubmit.py
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,7 @@ def mons(self, origin: str, timestamp: float, map_proto: dict, mitm_mapper):
if encounter_id < 0:
encounter_id = encounter_id + 2 ** 64

mitm_mapper.collect_mon_stats(origin, str(encounter_id))
cache_key = "mon{}-{}".format(encounter_id, mon_id)
if cache.exists(cache_key):
continue
Expand All @@ -82,8 +83,6 @@ def mons(self, origin: str, timestamp: float, map_proto: dict, mitm_mapper):
costume = pokemon_display.get('costume_value')
form = pokemon_display.get('form_value')

mitm_mapper.collect_mon_stats(origin, str(encounter_id))

now = datetime.utcfromtimestamp(time.time()).strftime("%Y-%m-%d %H:%M:%S")

# get known spawn end time and feed into despawn time calculation
Expand Down Expand Up @@ -231,11 +230,13 @@ def mon_iv(self, origin: str, timestamp: float, encounter_proto: dict, mitm_mapp
pokemon_display = pokemon_data.get("display", {})
mon_id = pokemon_data.get("id")
weather_boosted = pokemon_display.get("weather_boosted_value")
shiny = pokemon_display.get("is_shiny", 0)
spawnid = int(str(wild_pokemon["spawnpoint_id"]), 16)

if encounter_id < 0:
encounter_id = encounter_id + 2 ** 64

mitm_mapper.collect_mon_iv_stats(origin, encounter_id, int(shiny))
cache_key = "moniv{}-{}-{}".format(encounter_id, weather_boosted, mon_id)
if cache.exists(cache_key):
return
Expand All @@ -248,9 +249,6 @@ def mon_iv(self, origin: str, timestamp: float, encounter_proto: dict, mitm_mapp

latitude = wild_pokemon.get("latitude")
longitude = wild_pokemon.get("longitude")
shiny = pokemon_display.get("is_shiny", 0)

mitm_mapper.collect_mon_iv_stats(origin, encounter_id, int(shiny))

if getdetspawntime is None:
origin_logger.debug3("updating IV mon #{} at {}, {}. Despawning at {} (init)", pokemon_data["id"], latitude,
Expand Down

0 comments on commit 543c3d7

Please sign in to comment.