File tree Expand file tree Collapse file tree 1 file changed +9
-2
lines changed
backend/PyMatcha/routes/api Expand file tree Collapse file tree 1 file changed +9
-2
lines changed Original file line number Diff line number Diff line change 1919from flask import Blueprint
2020from flask import current_app
2121from flask import jsonify
22+ from flask_jwt_extended import current_user
2223from flask_jwt_extended import jwt_required
2324from PyMatcha .models .user import get_user
2425from PyMatcha .models .user import User
2526from PyMatcha .utils .errors import NotFoundError
26-
27+ from PyMatcha .utils .match_score import _get_common_tags
28+ from PyMatcha .utils .match_score import _get_distance
2729
2830user_bp = Blueprint ("user" , __name__ )
2931
@@ -47,7 +49,12 @@ def get_one_user(uid):
4749 pass
4850 else :
4951 current_app .logger .info (f"Returning info on user { uid } " )
50- return jsonify (u .to_dict ())
52+ returned_dict = u .to_dict ()
53+ user_tags = [t .name for t in u .get_tags ()]
54+ current_user_tags = [t .name for t in current_user .get_tags ()]
55+ returned_dict ["distance" ] = _get_distance (current_user .geohash , u .geohash )
56+ returned_dict ["common_tags" ] = _get_common_tags (current_user_tags , user_tags )
57+ return jsonify (returned_dict )
5158
5259
5360@user_bp .route ("/users/online" , methods = ["GET" ])
You can’t perform that action at this time.
0 commit comments