aboutsummaryrefslogtreecommitdiff
path: root/api/social/search.py
diff options
context:
space:
mode:
Diffstat (limited to 'api/social/search.py')
-rw-r--r--api/social/search.py3
1 files changed, 3 insertions, 0 deletions
diff --git a/api/social/search.py b/api/social/search.py
index ccc62e5..1159c67 100644
--- a/api/social/search.py
+++ b/api/social/search.py
@@ -13,10 +13,13 @@ def index():
if not query: return "", 400
if len(query) < 3: return "", 403
+ # use levenshtein with max distance 3 to search for users
+ #TODO: use mysql and sort by best match
results = cursor.execute("select user_id from users where levenshtein(lower(username), lower(?), 3)", [query]).fetchmany(20);
formatted = { "results": [] }
+ # get user_id for each result to prevent repeat user/info requests
for user in results:
formatted["results"].append(format_user(user[0]))