def report_main(): session = db.Session() top_pokemon = db.get_top_pokemon(session) bottom_pokemon = db.get_top_pokemon(session, order='ASC') bottom_sightings = db.get_all_sightings( session, [r[0] for r in bottom_pokemon] ) stage2_pokemon = db.get_stage2_pokemon(session) if stage2_pokemon: stage2_sightings = db.get_all_sightings( session, [r[0] for r in stage2_pokemon] ) else: stage2_sightings = [] js_data = { 'charts_data': { 'punchcard': db.get_punch_card(session), 'top30': [(POKEMON_NAMES[r[0]], r[1]) for r in top_pokemon], 'bottom30': [ (POKEMON_NAMES[r[0]], r[1]) for r in bottom_pokemon ], 'stage2': [ (POKEMON_NAMES[r[0]], r[1]) for r in stage2_pokemon ], }, 'maps_data': { 'bottom30': [sighting_to_marker(s) for s in bottom_sightings], 'stage2': [sighting_to_marker(s) for s in stage2_sightings], }, 'map_center': utils.get_map_center(), 'zoom': 13, } icons = { 'top30': [(r[0], POKEMON_NAMES[r[0]]) for r in top_pokemon], 'bottom30': [(r[0], POKEMON_NAMES[r[0]]) for r in bottom_pokemon], 'stage2': [(r[0], POKEMON_NAMES[r[0]]) for r in stage2_pokemon], 'nonexistent': [ (r, POKEMON_NAMES[r]) for r in db.get_nonexistent_pokemon(session) ] } session_stats = db.get_session_stats(session) session.close() area = utils.get_scan_area() return render_template( 'report.html', current_date=datetime.now(), area_name=config.AREA_NAME, area_size=area, total_spawn_count=session_stats['count'], spawns_per_hour=session_stats['per_hour'], session_start=session_stats['start'], session_end=session_stats['end'], session_length_hours=int(session_stats['length_hours']), js_data=js_data, icons=icons, google_maps_key=config.GOOGLE_MAPS_KEY, )
def report_main(): session = db.Session() top_pokemon = db.get_top_pokemon(session) bottom_pokemon = db.get_top_pokemon(session, order='ASC') bottom_sightings = db.get_all_sightings( session, [r[0] for r in bottom_pokemon] ) stage2_pokemon = db.get_stage2_pokemon(session) stage2_sightings = db.get_all_sightings( session, [r[0] for r in stage2_pokemon] ) js_data = { 'charts_data': { 'punchcard': db.get_punch_card(session), 'top30': [(pokemon_names[str(r[0])], r[1]) for r in top_pokemon], 'bottom30': [ (pokemon_names[str(r[0])], r[1]) for r in bottom_pokemon ], 'stage2': [ (pokemon_names[str(r[0])], r[1]) for r in stage2_pokemon ], }, 'maps_data': { 'bottom30': [sighting_to_marker(s) for s in bottom_sightings], 'stage2': [sighting_to_marker(s) for s in stage2_sightings], }, 'map_center': utils.get_map_center(), 'zoom': 13, } icons = { 'top30': [(r[0], pokemon_names[str(r[0])]) for r in top_pokemon], 'bottom30': [(r[0], pokemon_names[str(r[0])]) for r in bottom_pokemon], 'stage2': [(r[0], pokemon_names[str(r[0])]) for r in stage2_pokemon], 'nonexistent': [ (r, pokemon_names[str(r)]) for r in db.get_nonexistent_pokemon(session) ] } session_stats = db.get_session_stats(session) session.close() return render_template( 'report.html', current_date=datetime.now(), city=u'Wrocław', area=96, total_spawn_count=session_stats['count'], spawns_per_hour=session_stats['per_hour'], session_start=session_stats['start'], session_end=session_stats['end'], session_length_hours=int(session_stats['length_hours']), js_data=js_data, icons=icons, )
def report_main(): session = db.Session() top_pokemon = db.get_top_pokemon(session) bottom_pokemon = db.get_top_pokemon(session, order='ASC') bottom_sightings = db.get_all_sightings(session, [r[0] for r in bottom_pokemon]) stage2_pokemon = db.get_stage2_pokemon(session) stage2_sightings = db.get_all_sightings(session, [r[0] for r in stage2_pokemon]) js_data = { 'charts_data': { 'punchcard': db.get_punch_card(session), 'top30': [(pokemon_names[str(r[0])], r[1]) for r in top_pokemon], 'bottom30': [(pokemon_names[str(r[0])], r[1]) for r in bottom_pokemon], 'stage2': [(pokemon_names[str(r[0])], r[1]) for r in stage2_pokemon], }, 'maps_data': { 'bottom30': [sighting_to_marker(s) for s in bottom_sightings], 'stage2': [sighting_to_marker(s) for s in stage2_sightings], }, 'map_center': utils.get_map_center(), 'zoom': 13, } icons = { 'top30': [(r[0], pokemon_names[str(r[0])]) for r in top_pokemon], 'bottom30': [(r[0], pokemon_names[str(r[0])]) for r in bottom_pokemon], 'stage2': [(r[0], pokemon_names[str(r[0])]) for r in stage2_pokemon], 'nonexistent': [(r, pokemon_names[str(r)]) for r in db.get_nonexistent_pokemon(session)] } session_stats = db.get_session_stats(session) session.close() return render_template( 'report.html', current_date=datetime.now(), city=u'Wrocław', area=96, total_spawn_count=session_stats['count'], spawns_per_hour=session_stats['per_hour'], session_start=session_stats['start'], session_end=session_stats['end'], session_length_hours=int(session_stats['length_hours']), js_data=js_data, icons=icons, )
def search_top_pokemon(count, order, order_by='how_many'): session = db.Session() pokemons = db.get_top_pokemon(session,count,order, order_by) session.close for pokemon in pokemons: for pokedex_number,pokedex_name in pokemon_names.items(): if str(pokemon['pokemon_id']) == pokedex_number: pokemon.update({'name': pokedex_name}) return pokemons