-
-
Notifications
You must be signed in to change notification settings - Fork 79
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
1771 - API for Fetching Project Managers #1799
base: development
Are you sure you want to change the base?
Conversation
Want to review this pull request? Take a look at this documentation for a step by step guide! From your project repository, check out a new branch and test the changes.
|
@ntrehan just a heads up that your API req & res screenshot is currently broken / doesn't populate. |
Hi @pluto-bell Thanks for pointing that out! |
if (!userProjectMap[user]) { | ||
userProjectMap[user] = []; | ||
} | ||
userProjectMap[user].push(project.name); |
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.
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 a good catch
If Note: it returns the test data because we're running it locally. It will the actual data for the production environment.
|
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.
Requesting clarification and changes on API
- will user object be populated for each entry?
- Can we switch to an array instead of an object so that the frontend doesnt need to duplicate data for users with more than one managed project?
Thanks for putting so much work into getting this over then hill!
@@ -67,4 +67,26 @@ ProjectController.destroy = async function (req, res) { | |||
}; | |||
|
|||
|
|||
ProjectController.getProjectManagers = async function (req, res) { | |||
try { | |||
const userProjectMap = {}; |
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.
I think we want an array of objects of shape:
const userProjectMap = []; //changed to array
// Object shape from API call
{
user, // will this just be the userId string or will
// we have a populated user object with email, etc?
project: {
name: string
projectId: string
}
}
Does that look right to you? Then we'd be returning an array that can be sorted more easily on the front end with some sort functions
userProjectMap[user].push(project.name); | ||
} | ||
} | ||
return res.status(200).send(userProjectMap); |
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.
Am I right in understanding that the final out of the array (or object if thats the structure we go with) will only have user IDs? Do we need to make a second db call to populate the user object?
Fixes #1771
What changes did you make and why did you make them ?
Screenshots of Proposed Changes Of The Website
The API request and response
![image](https://github.com/user-attachments/assets/94a1f998-7e98-4506-a537-6125f23eacc7)