Commit 1036ac20 authored by Sorrel Harriet's avatar Sorrel Harriet
Browse files

updating leaderboard

parent 38419380
......@@ -57,7 +57,7 @@ def record_game(cursor, form_data):
# the game was not recorded
return False
def leaderboard():
def leaderboard(cursor):
""" The leaderboard component
#TODO: make it output the query results row by row
in a for loop - a job for a `proper' template engine?
......@@ -70,7 +70,12 @@ def leaderboard():
"GROUP BY username "
"ORDER BY num_wins/num_plays DESC")
# execute the query
cursor.execute(query, data)
# check we got something back
for (player, num_plays, num_wins) in cursor:
print("<p>{} won {} of {} games</p>".format(player, str(num_wins), str(num_plays)))
# finish this component...
print( utils.render_template( config['TEMPLATE_DIR'] + 'leaderboard.html') )
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment