RealDevSquad / RealDevSquad/website-backend

PATCH /users/self controller is ambiguous, and slow.

Open
#2,155 0 comments 0 reactions 1 assignee View on GitHub

@shubhdevelop is already working on this.

Since Oct 15, 2024.

Dominant language
JavaScript
Stars
74
Forks
276
Avg merge
1d 26m
Merged PRs (30d)
14

Description

Issue Description

PATCH /users/self is going to be deprecated` but the controller logic stays.

The Patch /users/self routes, doesn't allow the developers to update their profile data.
By developers we mean those users who are in the discord server, whom user Details is not incomplete and have developers role added to them.
For user to update their profile data we suggest them to use Profile service.

we are fetching all the user in RDS server from the discord, in order to check if the user has developer role or not , using the discord service, this shoots up the response time in certain cases, the latency is in magnitude of O(n) where n is the number of users currently in the discord service

Expected Behaviour

If a request is made to the route PATCH /users/self with some data in the body: partial<UserObject> it is the expectation that it should update user data with all that is being sent in the body .

Fast Response Time

Current Behaviour

If we send a request with object

body: {
      username:string
}

it return can't update the username twice -> expected

body:{
   roles:{
         super_user: true/false
  }
}

it return can't modify roles --> expected

For other properties we don't allow users to update their profile data, if the user is a developer, (in_discord==true && !userDetailsIncomplete). then we fetch all the user from discrod server and check if the current logged in users discordId is equal to the discord.user.id. in worst case this the it take up to O(n) time if the user returned is found to be at end.

ps: this route is generally used to add details to user once they are signed up or has their userDetailsIncomplete property true.

Flow

image

Reproducibility
  • This issue is reproducible
  • This issue is not reproducible
Steps to Reproduce

send the objects mentioned in current behavior section on PATCH /users/self.

Severity/Priority
  • Critical
  • High
  • Medium
  • Low
Additional Information
Checklist
  • I have read and followed the project's code of conduct.
  • I have searched for similar issues before creating this one.
  • I have provided all the necessary information to understand and reproduce the issue.
  • I am willing to contribute to the resolution of this issue.

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.