def update_topN(c, g, n): if topN_count(c) >= n: if g['sc'] > lowest_highscore(c): query_do(c,'''DELETE FROM top_games WHERE id = %s''', query_first(c, '''SELECT id FROM top_games ORDER BY sc LIMIT 1''')) insert_game(c, g, 'top_games') lowest_highscore.flush() dirty_pages('top-N', 'overview') else: insert_game(c, g, 'top_games') dirty_pages('top-N', 'overview') topN_count.flush()
def update_topN(c, g, n): if topN_count(c) >= n: if g['sc'] > lowest_highscore(c): query_do( c, '''DELETE FROM top_games WHERE id = %s''', query_first( c, '''SELECT id FROM top_games ORDER BY sc LIMIT 1''')) insert_game(c, g, 'top_games') lowest_highscore.flush() dirty_pages('top-N', 'overview') else: insert_game(c, g, 'top_games') dirty_pages('top-N', 'overview') topN_count.flush()
def update_topN(c, g, n): if topN_count(c) >= n: if g['sc'] > lowest_highscore(c): # note: for some reason this particular query is faster than just a simple # DELETE FROM ... ORDER BY query. query_do(c,'''DELETE FROM top_games WHERE id = %s''', query_first(c, '''SELECT id FROM top_games ORDER BY sc LIMIT 1''')) insert_game(c, g, 'top_games') lowest_highscore.flush() dirty_pages('top-N', 'overview') else: insert_game(c, g, 'top_games') dirty_pages('top-N', 'overview') topN_count.flush()
def update_player_streak(c, g): player = g['name'] win = game_is_win(g) if not win: if player_streak_is_active(c, player): player_break_streak(c, player, g) player_streak_is_active.flush_key(player) dirty_pages('streaks', 'overview') dirty_player(player) else: if player_streak_is_active(c, player): player_extend_streak(c, player, g) dirty_pages('streaks', 'overview') elif player_won_last_game(c, player): player_create_streak(c, player, g) dirty_pages('streaks', 'overview') player_streak_is_active.flush_key(player)
def update_wins_table(c, g): if game_is_win(g): dirty_pages('winners', 'fastest-wins-turns', 'fastest-wins-time', 'overview') insert_game(c, g, 'wins')
def update(self, g): if not game_is_win(g) or game_is_buggy(g): return dirty_pages('winners', 'fastest-wins-turns', 'fastest-wins-time', 'overview') self.games.append(g)