def update_player_recent_games(c, g): player = g['name'] insert_game(c, g, 'player_recent_games') if player_recent_game_count.has_key(player): player_recent_game_count.set_key(player_recent_game_count(c, player) + 1, player) if player_recent_game_count(c, player) > MAX_PLAYER_RECENT_GAMES + 50: extra = player_recent_game_count(c, player) - MAX_PLAYER_RECENT_GAMES ids = query_first_col(c, '''SELECT id FROM player_recent_games WHERE name = %s ORDER BY id LIMIT %s''', player, extra) scload.delete_table_rows_by_id(c, 'player_recent_games', ids) player_recent_game_count.flush_key(player)
def update_player_recent_games(c, g): player = g['name'] insert_game(c, g, 'player_recent_games') if player_recent_game_count.has_key(player): player_recent_game_count.set_key( player_recent_game_count(c, player) + 1, player) if player_recent_game_count(c, player) > MAX_PLAYER_RECENT_GAMES + 50: extra = player_recent_game_count(c, player) - MAX_PLAYER_RECENT_GAMES ids = query_first_col( c, '''SELECT id FROM player_recent_games WHERE name = %s ORDER BY id LIMIT %s''', player, extra) scload.delete_table_rows_by_id(c, 'player_recent_games', ids) player_recent_game_count.flush_key(player)
def update_player_recent_games(c, g): player = g['name'] insert_game(c, g, 'player_recent_games') if player_recent_game_count.has_key(player): player_recent_game_count.set_key(player_recent_game_count(c, player) + 1, player) if player_recent_game_count(c, player) > MAX_PLAYER_RECENT_GAMES + 50: extra = player_recent_game_count(c, player) - MAX_PLAYER_RECENT_GAMES ids = query_first_col(c, '''SELECT id FROM player_recent_games WHERE name = %s ORDER BY id LIMIT %s''', player, extra) query_do(c, '''DELETE FROM player_recent_games WHERE id IN (%s)''', ",".join([str(x) for x in ids])) player_recent_game_count.flush_key(player)
def update_all_recent_games(c, g): if is_junk_game(g): return dirty_page('recent', 1) dirty_page('per-day', 1) insert_game(c, g, 'all_recent_games') if all_recent_game_count.has_key(): all_recent_game_count.set_key(all_recent_game_count(c) + 1) if all_recent_game_count(c) > MAX_ALL_RECENT_GAMES + 50: extra = all_recent_game_count(c) - MAX_ALL_RECENT_GAMES ids = query_first_col(c, '''SELECT id FROM all_recent_games ORDER BY id LIMIT %s''', extra) scload.delete_table_rows_by_id(c, 'all_recent_games', ids) all_recent_game_count.flush_key()
def update_all_recent_games(c, g): if is_junk_game(g): return dirty_page('recent', 1) dirty_page('per-day', 1) insert_game(c, g, 'all_recent_games') if all_recent_game_count.has_key(): all_recent_game_count.set_key(all_recent_game_count(c) + 1) if all_recent_game_count(c) > MAX_ALL_RECENT_GAMES + 50: extra = all_recent_game_count(c) - MAX_ALL_RECENT_GAMES ids = query_first_col( c, '''SELECT id FROM all_recent_games ORDER BY id LIMIT %s''', extra) scload.delete_table_rows_by_id(c, 'all_recent_games', ids) all_recent_game_count.flush_key()
def update_all_recent_games(c, g): if is_junk_game(g): return dirty_page('recent', 1) dirty_page('per-day', 1) insert_game(c, g, 'all_recent_games') if all_recent_game_count.has_key(): all_recent_game_count.set_key(all_recent_game_count(c) + 1) if all_recent_game_count(c) > MAX_ALL_RECENT_GAMES + 50: extra = all_recent_game_count(c) - MAX_ALL_RECENT_GAMES ids = query_first_col(c, '''SELECT id FROM all_recent_games ORDER BY id LIMIT %s''', extra) query_do(c, '''DELETE FROM all_recent_games WHERE id IN (%s)''', ",".join([str(x) for x in ids])) all_recent_game_count.flush_key()
def all_races(c): scload.bootstrap_known_raceclasses(c) races = query_first_col(c, '''SELECT race FROM known_races''') races.sort() return races
def all_classes(c): scload.bootstrap_known_raceclasses(c) clx = query_first_col(c, '''SELECT cls FROM known_classes''') clx.sort() return clx
def find_all_players(c): return query_first_col(c, '''SELECT name FROM players''')
def find_all_players(c): return query_first_col(c, '''SELECT name FROM players ORDER BY name''')