Skip to content

Commit

Permalink
Fixes!
Browse files Browse the repository at this point in the history
- punch card chart should work for both mysql and sqlite
- don't store Pokemon with negative time_till_hidden
  • Loading branch information
modrzew committed Jul 30, 2016
1 parent 6b78aa7 commit 9497191
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 2 deletions.
8 changes: 6 additions & 2 deletions db.py
Original file line number Diff line number Diff line change
Expand Up @@ -149,13 +149,17 @@ def get_session_stats(session):


def get_punch_card(session):
if get_engine_name(session) == 'sqlite':
bigint = 'BIGINT'
else:
bigint = 'UNSIGNED'
query = session.execute('''
SELECT
CAST((expire_timestamp / 300) AS BIGINT) ts_date,
CAST((expire_timestamp / 300) AS {bigint}) ts_date,
COUNT(*) how_many
FROM `sightings`
GROUP BY ts_date ORDER BY ts_date
''')
'''.format(bigint=bigint))
results = query.fetchall()
results_dict = {r[0]: r[1] for r in results}
filled = []
Expand Down
5 changes: 5 additions & 0 deletions worker.py
Original file line number Diff line number Diff line change
Expand Up @@ -169,6 +169,11 @@ def main(self):
if map_objects.get('status') == 1:
for map_cell in map_objects['map_cells']:
for pokemon in map_cell.get('wild_pokemons', []):
# Care only about 15 min spawns
# 30 and 45 min ones will be just put after
# time_till_hidden is below 15 min
if pokemon['time_till_hidden_ms'] < 0:
continue
pokemons.append(self.normalize_pokemon(pokemon, now))
for raw_pokemon in pokemons:
db.add_sighting(session, raw_pokemon)
Expand Down

0 comments on commit 9497191

Please sign in to comment.