Skip to content

Commit

Permalink
Add spawnpoint type to pokemon webhook data. (#1759)
Browse files Browse the repository at this point in the history
* Add tth_found to pokemon data.

* Moved from tth_found_pct to spawnpoint type.
  • Loading branch information
sebastienvercammen committed Jan 29, 2017
1 parent f55ad0e commit 8ebaa2e
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 6 deletions.
3 changes: 2 additions & 1 deletion pogom/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -1789,7 +1789,8 @@ def parse_map(args, map_dict, step_location, db_update_queue, wh_update_queue,
'disappear_time': calendar.timegm(
disappear_time.timetuple()),
'last_modified_time': p['last_modified_timestamp_ms'],
'time_until_hidden_ms': p['time_till_hidden_ms']
'time_until_hidden_ms': p['time_till_hidden_ms'],
'verified': SpawnPoint.tth_found(sp)
})
wh_update_queue.put(('pokemon', wh_poke))

Expand Down
18 changes: 13 additions & 5 deletions pogom/search.py
Original file line number Diff line number Diff line change
Expand Up @@ -514,15 +514,23 @@ def search_overseer_thread(args, new_location_queue, pause_bit, heartb,
time.sleep(1)


def get_scheduler_tth_found_pct(scheduler):
tth_found_pct = getattr(scheduler, 'tth_found', 0)

if tth_found_pct > 0:
# Avoid division by zero. Keep 0.0 default for consistency.
active_sp = max(getattr(scheduler, 'active_sp', 0.0), 1.0)
tth_found_pct = tth_found_pct * 100.0 / float(active_sp)

return tth_found_pct


def wh_status_update(args, status, wh_queue, scheduler):
scheduler_name = status['scheduler']

if args.speed_scan:
tth_found = getattr(scheduler, 'tth_found', -1)
tth_found = get_scheduler_tth_found_pct(scheduler)
spawns_found = getattr(scheduler, 'spawns_found', 0)
if tth_found > -1:
# Avoid division by zero. Keep 0.0 default for consistency.
active_sp = max(getattr(scheduler, 'active_sp', 0.0), 1.0)
tth_found = tth_found * 100.0 / float(active_sp)

if (tth_found - status['scheduler_status']['tth_found']) > 0.01:
log.debug("Scheduler update is due, sending webhook message.")
Expand Down

0 comments on commit 8ebaa2e

Please sign in to comment.