Skip to content
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

Changing user/me route to include all home info #165

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 7 additions & 7 deletions backend/package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 2 additions & 2 deletions backend/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -23,11 +23,11 @@
"express": "^4.18.2",
"express-validator": "^6.14.3",
"firebase-admin": "^11.5.0",
"firebase-functions": "^4.4.1",
"mongoose": "^6.8.4",
"multer": "^1.4.5-lts.1",
"pug": "^3.0.2",
"sharp": "^0.31.3",
"firebase-functions": "^4.3.1"
"sharp": "^0.31.3"
},
"devDependencies": {
"@types/express": "^4.17.15",
Expand Down
42 changes: 31 additions & 11 deletions backend/src/routes/user.ts
Original file line number Diff line number Diff line change
Expand Up @@ -563,9 +563,19 @@ router.get(
getPastSessionPromise,
getPairedMentorIdPromise,
]);
const mentor = await Mentor.findById(pairedMentorId);
if (!mentor) {
throw ServiceError.MENTOR_WAS_NOT_FOUND;
}
res.status(200).send({
status: mentee.status,
sessionId: upcomingSessionId ?? pastSessionId,
name: mentee.name,
mentorName: mentor?.name ?? "N/A",
mentorMajor: mentor?.major ?? "N/A",
mentorUniversity: mentor?.college ?? "N/A",
mentorCareer: mentor?.career ?? "N/A",
upcomingSessionId: upcomingSessionId ?? "N/A",
pastSessionId: pastSessionId ?? "N/A",
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think it's good that we're returning both the upcoming session id and past session id. I was just wondering if in the session document we store some field to state whether a session was canceled or rescheduled. I only ask because on Frontend we have to update the session card based on whether a session is scheduled, canceled, or rescheduled for the mentee home page. If you think that we can implement that feature on the Home Page with the current route as it stands then I think its good to merge. Otherwise, it might be useful to look into changing the sessions route to reflect whether a session was canceled, rescheduled, or no changes.

pairedMentorId,
});
} else if (role === "mentor") {
Expand All @@ -581,23 +591,33 @@ router.get(
return;
}

const getMenteeIdsPromises = mentor.pairingIds.map(async (pairingId) =>
getMenteeId(pairingId)
);
// // For MVP, we assume there is only 1 mentee 1 mentor pairing
// const getMenteeIdsPromise = getMenteeIdsPromises[0];

// For MVP, we assume there is only 1 mentee 1 mentor pairing
const getMenteeIdsPromise = getMenteeIdsPromises[0];

const [upcomingSessionId, pastSessionId, pairedMenteeId] = await Promise.all([
const [upcomingSessionId, pastSessionId] = await Promise.all([
getUpcomingSessionPromise,
getPastSessionPromise,
getMenteeIdsPromise,
]);

const menteeIds = await Promise.all(mentor.pairingIds.map(getMenteeId));
const mentees = await Promise.all(menteeIds.map((menteeId) => Mentee.findById(menteeId)));
const menteeNames = mentees.map((mentee) => mentee?.name ?? "N/A");

// const menteeNames = await Promise.all(
// pairedIds.map(async (pairedId) => {
// console.log(pairedId)
// const mentee = await Mentee.findById(pairedId);
// return mentee?.name ?? "N/A";
// })
// );

res.status(200).send({
status: mentor.status,
sessionId: upcomingSessionId ?? pastSessionId,
pairedMenteeId,
name: mentor.name,
menteeNames: menteeNames ?? [],
upcomingSessionId: upcomingSessionId ?? "N/A",
pastSessionId: pastSessionId ?? "N/A",
pairedIds: menteeIds,
});
return;
}
Expand Down
Loading