From a48947585eaca16dd64ae534d928698f88ee6150 Mon Sep 17 00:00:00 2001 From: Timotej Lazar Date: Tue, 13 Oct 2015 12:04:02 +0200 Subject: Store robot's address in settings --- server/user_session.py | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) (limited to 'server/user_session.py') diff --git a/server/user_session.py b/server/user_session.py index 9338c2c..9d8a675 100644 --- a/server/user_session.py +++ b/server/user_session.py @@ -66,7 +66,7 @@ class UserSession(object): try: cur = conn.cursor() try: - cur.execute('select id, password, name, email, date_joined, gui_lang from codeq_user where username = %s', (username,)) + cur.execute('select id, password, name, email, date_joined, gui_lang, robot_address from codeq_user where username = %s', (username,)) row = cur.fetchone() if row is None: raise AuthenticationFailed('No such user: {}'.format(username)) @@ -74,7 +74,7 @@ class UserSession(object): cur.execute('update codeq_user set last_login = %s where id = %s', (str(now), row[0],)) self.uid = row[0] self.username = username - self.settings = {'gui_lang': row[5]} + self.settings = {'gui_lang': row[5], 'robot_address': row[6]} return row[2], row[3], row[4], now else: raise AuthenticationFailed('Password mismatch') @@ -142,7 +142,7 @@ class UserSession(object): try: cur = conn.cursor() try: - cur.execute("update codeq_user set gui_lang = %s where id = %s", (self.settings['gui_lang'], self.uid)) + cur.execute("update codeq_user set gui_lang = %s, robot_address = %s where id = %s", (self.settings['gui_lang'], self.settings['robot_address'], self.uid)) finally: cur.close() finally: -- cgit v1.2.1 From 4cef12f77d73303226ea5ebc8889f6c2cc4ca958 Mon Sep 17 00:00:00 2001 From: Timotej Lazar Date: Tue, 13 Oct 2015 15:03:54 +0200 Subject: Use identifiers instead of names in get_stat Names have been removed from the database. This code will be updated when we decide what statistics to present to the user. --- server/user_session.py | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) (limited to 'server/user_session.py') diff --git a/server/user_session.py b/server/user_session.py index 9d8a675..41c77ac 100644 --- a/server/user_session.py +++ b/server/user_session.py @@ -266,9 +266,9 @@ class UserSession(object): cur.execute("""select * from( (SELECT distinct - l.name as language, + l.identifier as language, pg.id as problem_group_id, - pg.name as problem_group, + pg.identifier as problem_group, count(distinct p.id) as all, count(CASE s.done WHEN true THEN true END) as done, count(CASE s.done WHEN false THEN true END) as in_progress @@ -276,11 +276,11 @@ class UserSession(object): INNER JOIN language l ON p.language_id = l.id INNER JOIN problem_group pg ON p.problem_group_id = pg.id LEFT JOIN solution s ON s.problem_id = p.id AND s.codeq_user_id = %s - GROUP BY l.name, pg.id, pg.name) + GROUP BY l.identifier, pg.id, pg.identifier) UNION ALL (SELECT distinct - l.name as language, + l.identifier as language, 0 as problem_group_id, null as problem_group, count(distinct p.id) as all, @@ -289,7 +289,7 @@ class UserSession(object): FROM problem p INNER JOIN language l ON p.language_id = l.id LEFT JOIN solution s ON s.problem_id = p.id AND s.codeq_user_id = %s - GROUP BY l.name) + GROUP BY l.identifier) ) as u ORDER BY u.language, problem_group_id""", (uid, uid,)) #return cur.fetchall() -- cgit v1.2.1