diff --git a/mocha_server.py b/mocha_server.py index b739051..83870db 100755 --- a/mocha_server.py +++ b/mocha_server.py @@ -72,9 +72,11 @@ def fetch_user(user_id): conn.row_factory = sqlite3.Row cursor = conn.cursor() if user_id != '*': # must use (?), (item,) format - cursor.execute('SELECT * FROM users WHERE user_id=(?)', (user_id, )) + cursor.execute( + 'SELECT * FROM users WHERE user_id=(?) ORDER BY score DESC', + (user_id, )) else: - cursor.execute('SELECT * FROM users') + cursor.execute('SELECT * FROM users ORDER BY score DESC') output = cursor.fetchall() output = json.dumps([dict(row) for row in output]) @@ -155,7 +157,6 @@ def application(environ, start_response): if __name__ == '__main__': - print(fetch_top_n(3)) - + print(fetch_user('*')) # vim: tabstop=4 shiftwidth=4 softtabstop=4 expandtab