def winner_stats(c): rows = query_rows(c, '''SELECT p.games_won, p.name, p.games_played, p.max_runes, p.best_score, p.total_score, ''' + logfields_prefixed('g.') + ''' FROM players p, player_best_games g WHERE p.name = g.name AND p.best_score = g.sc AND p.games_won > 0 ORDER BY p.games_won DESC, p.games_played, p.best_score DESC''') results = [] for r in rows: results.append(list(r[0:3]) + [calc_perc_pretty(r[0], r[2]) + '%', r[3], linked_text(row_to_xdict(r[6:]), morgue_link, human_number(r[4])), human_number(r[5]), human_number(calc_avg_int(r[5], r[2]))]) return results
def winner_stats(c): rows = query_rows( c, '''SELECT p.games_won, p.name, p.games_played, p.max_runes, p.best_score, p.total_score, ''' + logfields_prefixed('g.') + ''' FROM players p, player_best_games g WHERE p.name = g.name AND p.best_score = g.sc AND p.games_won > 0 ORDER BY p.games_won DESC, p.games_played, p.best_score DESC''') results = [] for r in rows: results.append( list(r[0:3]) + [ calc_perc_pretty(r[0], r[2]) + '%', r[3], linked_text(row_to_xdict(r[6:]), morgue_link, human_number( r[4])), human_number(r[5]), human_number(calc_avg_int(r[5], r[2])) ]) return results
def fixup_column(col, data, game): if col.find('time') != -1: return pretty_date(data) elif col.find('dur') != -1: return pretty_dur(data) elif col == 'place' and game.get('ktyp') == 'winning': return '' elif (isinstance(data, (int,long)) and (col == 'sc' or col == 'turn' or col.lower().find('score') != -1)): return human_number(data) return data
def fixup_column(col, data, game): if col.find('time') != -1: return pretty_date(data) elif col.find('dur') != -1: return pretty_dur(data) elif col == 'place' and game.get('ktyp') == 'winning': return '' elif (isinstance(data, (int, long)) and (col == 'sc' or col == 'turn' or col.lower().find('score') != -1)): return human_number(data) return data
def fixup_player_stats(c, rl): games = player_best_first_last(c, rl[0]) rl[5] = linked_text(games[0], morgue_link, human_number(rl[5])) rl[6] = linked_text(games[1], morgue_link, rl[6]) rl[7] = linked_text(games[2], morgue_link, rl[7]) win_perc = calc_perc_pretty(rl[2], rl[1]) + "%" avg_score = calc_avg_int(rl[3], rl[1]) return { 'total_score': rl[3], 'name': rl[0], 'games_played': rl[1], 'games_won': rl[2], 'win_perc': win_perc, 'best_xl': rl[4], 'best_score': rl[5], 'avg_score': avg_score, 'first_game': rl[6], 'last_game': rl[7] }
def best_players_by_total_score(c): rows = query_rows(c, '''SELECT name, games_played, games_won, total_score, best_score, first_game_start, last_game_end FROM players WHERE total_score > 500 ORDER BY total_score DESC''') res = [] for r in rows: rl = list(r) games = player_best_first_last(c, rl[0]) rl[4] = linked_text(games[0], morgue_link, human_number(rl[4])) rl[5] = linked_text(games[1], morgue_link, rl[5]) rl[6] = linked_text(games[2], morgue_link, rl[6]) win_perc = calc_perc_pretty(rl[2], rl[1]) + "%" avg_score = calc_avg_int(rl[3], rl[1]) res.append([rl[3]] + list(rl[0:3]) + [win_perc] + [rl[4]] + [avg_score] + list(rl[5:])) return res
def best_players_by_total_score(c): rows = query_rows( c, '''SELECT name, games_played, games_won, total_score, best_score, first_game_start, last_game_end FROM players WHERE total_score > 500 ORDER BY total_score DESC''') res = [] for r in rows: rl = list(r) games = player_best_first_last(c, rl[0]) rl[4] = linked_text(games[0], morgue_link, human_number(rl[4])) rl[5] = linked_text(games[1], morgue_link, rl[5]) rl[6] = linked_text(games[2], morgue_link, rl[6]) win_perc = calc_perc_pretty(rl[2], rl[1]) + "%" avg_score = calc_avg_int(rl[3], rl[1]) res.append([rl[3]] + list(rl[0:3]) + [win_perc] + [rl[4]] + [avg_score] + list(rl[5:])) return res