summaryrefslogtreecommitdiff
path: root/server
diff options
context:
space:
mode:
Diffstat (limited to 'server')
-rw-r--r--server/user_session.py16
1 files changed, 8 insertions, 8 deletions
diff --git a/server/user_session.py b/server/user_session.py
index 9338c2c..41c77ac 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:
@@ -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()