From 10a13f74e68d2870a92b54f9dd6fb5610b501242 Mon Sep 17 00:00:00 2001 From: Corder Guy Date: Thu, 19 Apr 2018 14:12:51 -0500 Subject: [PATCH] Order user responses by score --- mocha_server.py | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) 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