-
Notifications
You must be signed in to change notification settings - Fork 263
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Refactor getUser controller function based on query parameter #2370
base: develop
Are you sure you want to change the base?
Refactor getUser controller function based on query parameter #2370
Conversation
26351df
to
3b2fefe
Compare
3b2fefe
to
47b8ba9
Compare
…ameters Signed-off-by: Prakhar Kumar <prakhar.meerut@gmail.com>
Signed-off-by: Prakhar Kumar <prakhar.meerut@gmail.com>
Signed-off-by: Prakhar Kumar <prakhar.meerut@gmail.com>
…for reusability. 2. Updated the integration tests after refactoring of code. Signed-off-by: Prakhar Kumar <prakhar.meerut@gmail.com>
b733ceb
to
220e533
Compare
…ryparam Signed-off-by: Prakhar Kumar <prakhar.meerut@gmail.com>
return res.json({ | ||
message: "User returned successfully!", | ||
user, | ||
message: user ? "User returned successfully!" : "User not found", |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
why this change?
count: usersData.length, | ||
users: usersData, | ||
message: "No users found", | ||
users: [], |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
why we removed the count field?
user = result.user; | ||
if (!result.userExists) { | ||
return null; | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
why are we not throwing error here?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is the original functionality haven't changed the code, just refactored it, if i throw error here. Tests will fail as it would require null user but we would return a 404 status code.
Date: 26 Jan 2025
Developer Name: Prakhar Kumar
Issue Ticket Number
Description
Refactored get users function in user controller by decomposing into smaller functions based on query parameters.
Documentation Updated?
Under Feature Flag
Database Changes
Breaking Changes
Development Tested?
Screenshots
Test Coverage
Additional Notes
Tejas Sir has asked for a peer review for the PR and then design doc can be discussed.
Design Doc - https://docs.google.com/document/d/19cs4FndY-Rh37A7ptZ2db9S-1Mqd2BICwpWV-SZJQv4/edit?tab=t.0#heading=h.o43h9priqbg
TCR - https://dashboard.realdevsquad.com/task-requests/details/?id=65zapL8S5y4mm9M2bPzC