aboutsummaryrefslogtreecommitdiff
path: root/api/user/info.py
diff options
context:
space:
mode:
authorlonkaars <l.leblansch@gmail.com>2021-04-11 18:03:11 +0200
committerlonkaars <l.leblansch@gmail.com>2021-04-11 18:03:11 +0200
commitdeb09e5c749e3353c927d7fe94bbd35f25ff85ee (patch)
tree702ba982530aa98a96ddece365a32be842dae3c2 /api/user/info.py
parent28f104de9ae9abe4b42abafbf3865ede5687996c (diff)
dprint yapf continuation align style edit
Diffstat (limited to 'api/user/info.py')
-rw-r--r--api/user/info.py46
1 files changed, 23 insertions, 23 deletions
diff --git a/api/user/info.py b/api/user/info.py
index de0d2e8..ee20814 100644
--- a/api/user/info.py
+++ b/api/user/info.py
@@ -8,7 +8,7 @@ import json
# check if user_id exists in database
def valid_user_id(user_id):
query = cursor.execute(
- "select user_id from users where user_id = ?", [user_id]
+ "select user_id from users where user_id = ?", [user_id]
).fetchone()
return bool(query)
@@ -16,8 +16,8 @@ def valid_user_id(user_id):
# get relation to user_2_id from user_1_id's perspective
def get_relation_to(user_1_id, user_2_id):
relation = cursor.execute("select * from social where " + \
- "(user_1_id = ? and user_2_id = ?) or " + \
- "(user_1_id = ? and user_2_id = ?)", [user_1_id, user_2_id, user_2_id, user_1_id]).fetchone()
+ "(user_1_id = ? and user_2_id = ?) or " + \
+ "(user_1_id = ? and user_2_id = ?)", [user_1_id, user_2_id, user_2_id, user_1_id]).fetchone()
if not relation: return "none"
if relation[2] == "friendship": return "friends"
if relation[2] == "outgoing" and relation[0] == user_1_id:
@@ -31,8 +31,8 @@ def get_relation_to(user_1_id, user_2_id):
# get users friend count
def count_friends(user_id):
query = cursor.execute(
- "select type from social where (user_1_id = ? or user_2_id = ?) and type = \"friendship\"",
- [user_id, user_id]
+ "select type from social where (user_1_id = ? or user_2_id = ?) and type = \"friendship\"",
+ [user_id, user_id]
).fetchall()
return len(query) #FIXME: use SQL count() instead of python's len()
@@ -40,25 +40,25 @@ def count_friends(user_id):
# get user/info of `user_id` as `viewer` (id)
def format_user(user_id, viewer=''):
user = cursor.execute(
- "select " + ", ".join(
- [
- "username",
- "user_id",
- "country",
- "registered",
- "status",
- ]
- ) + " from users where user_id = ?", [user_id]
+ "select " + ", ".join(
+ [
+ "username",
+ "user_id",
+ "country",
+ "registered",
+ "status",
+ ]
+ ) + " from users where user_id = ?", [user_id]
).fetchone()
formatted_user = {
- "username": user[0],
- "id": user[1],
- "country": user[2],
- "registered": user[3],
- "status": user[4],
- "friends": count_friends(user_id),
- "rating":
- get_rating(user_id), #TODO: calculate rating based on game analysis
+ "username": user[0],
+ "id": user[1],
+ "country": user[2],
+ "registered": user[3],
+ "status": user[4],
+ "friends": count_friends(user_id),
+ "rating":
+ get_rating(user_id), #TODO: calculate rating based on game analysis
}
if viewer:
#FIXME: validate viewer id?
@@ -86,7 +86,7 @@ def index():
if username:
temp_user_id = cursor.execute(
- "select user_id from users where username = ?", [username]
+ "select user_id from users where username = ?", [username]
).fetchone()
if len(temp_user_id) > 0: user_id = temp_user_id