diff options
author | lonkaars <l.leblansch@gmail.com> | 2021-03-14 15:07:51 +0100 |
---|---|---|
committer | lonkaars <l.leblansch@gmail.com> | 2021-03-14 15:07:51 +0100 |
commit | 8a9060d5dcdc67d14fb5b1b6e856d9ea39ffb618 (patch) | |
tree | eeaf0178fdc2e90e85f3f0f89d4272618ab0f4db /api/user | |
parent | f6e46892723059efe3ad7666f94d476c7d350c2c (diff) |
friend count + dutch grammar on /user
Diffstat (limited to 'api/user')
-rw-r--r-- | api/user/info.py | 5 |
1 files changed, 5 insertions, 0 deletions
diff --git a/api/user/info.py b/api/user/info.py index e720e56..b60593e 100644 --- a/api/user/info.py +++ b/api/user/info.py @@ -18,6 +18,10 @@ def get_relation_to(user_1_id, user_2_id): if relation[2] == "block" and relation[0] == user_1_id: return "blocked" return "none" +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]).fetchall() + return len(query) + def format_user(user_id, viewer = ''): user = cursor.execute("select " + ", ".join([ "username", @@ -34,6 +38,7 @@ def format_user(user_id, viewer = ''): "registered": user[3], "avatar": user[4], "status": user[5], + "friends": count_friends(user_id) } if viewer: formatted_user["relation"] = get_relation_to(viewer, user_id) |