Skip to content

Commit

Permalink
Update user.py
Browse files Browse the repository at this point in the history
  • Loading branch information
jonathanjma authored Feb 13, 2024
1 parent ae2a65a commit 8e915d4
Showing 1 changed file with 5 additions and 6 deletions.
11 changes: 5 additions & 6 deletions happiness-backend/api/routes/user.py
Original file line number Diff line number Diff line change
Expand Up @@ -332,10 +332,9 @@ def user_count(req):
Returns the number of happiness entries that the user has made on happiness app and the number of groups that
the user is in.
"""
user_id = req.get("user_id", token_auth.current_user().id)
if not (user_id == token_auth.current_user().id or
token_auth.current_user().has_mutual_group(users_dao.get_user_by_id(user_id))):
user_id = req.get("user_id", token_current_user().id)
if not (user_id == token_current_user().id or
token_current_user().has_mutual_group(users_dao.get_user_by_id(user_id))):
return failure_response("Not Allowed.", 403)
q = token_current_user().groups
n = q.count()
return {"entries": happiness_dao.get_num_of_entries(user_id, low=0, high=10), "groups": n}
num_groups = token_current_user().groups.count()
return {"entries": happiness_dao.get_num_of_entries(user_id, low=0, high=10), "groups": num_groups}

0 comments on commit 8e915d4

Please sign in to comment.