diff --git a/__pycache__/mocha_server.cpython-36.pyc b/__pycache__/mocha_server.cpython-36.pyc index 7c2ae9e..67d795d 100644 Binary files a/__pycache__/mocha_server.cpython-36.pyc and b/__pycache__/mocha_server.cpython-36.pyc differ diff --git a/mocha.db b/mocha.db index 6f7a339..0a4abfe 100644 Binary files a/mocha.db and b/mocha.db differ diff --git a/mocha_server.py b/mocha_server.py index 536f204..2a2f009 100755 --- a/mocha_server.py +++ b/mocha_server.py @@ -19,6 +19,15 @@ cursor = conn.cursor() # TODO: Add fetching of top N users by score # TODO: Add ability to store and retrieve avatars (as image files?) +def update_steps(user_id, steps): + """ + Overwrites the old raw_steps value. + This can be changed to increment it if needed. + """ + cursor.execute("update users set raw_steps=? where user_id=?", (steps, user_id)) + conn.commit() + + def get_users(username_list): """ Gets a list of users searching by name. @@ -74,7 +83,6 @@ def insert_row(user_id, username): Inserts a row for a NEW user with given parameters This may work better with AUTOINCREMENT to avoid arbitrary ids and duplicates """ - cursor.execute("insert into users values (?,?)", (user_id, username)) conn.commit() #conn.close() diff --git a/test.py b/test.py index 9cf54e4..7b138e4 100644 --- a/test.py +++ b/test.py @@ -8,5 +8,7 @@ import mocha_server username_list = ['andrew', 'Corder'] -print(mocha_server.get_users(username_list)) +mocha_server.update_steps(4, 1234) +mocha_server.update_steps(2, 5678) +print(mocha_server.get_users(username_list))