-
Notifications
You must be signed in to change notification settings - Fork 42
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
Implement Get all mentors endpoint (Admin) #24 #67
Conversation
let adminAgent: supertest.SuperAgentTest | ||
let mentorId: string | ||
|
||
describe('getAllMentors function', () => { |
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 should be route testing. Move to the src/routes/admin/mentor/mentor.route.test.ts
file
src/services/admin/mentor.service.ts
Outdated
status: ApplicationStatus | ||
): Promise<{ | ||
statusCode: number | ||
mentors?: AllMentorsArray[] |
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.
We do have the Mentor interface. Use that.
mentors?: AllMentorsArray[] | |
mentors?: Mentor[] |
src/services/admin/mentor.service.ts
Outdated
const mentorRepository = dataSource.getRepository(Mentor) | ||
|
||
const mentorsList: Mentor[] = await mentorRepository.find({ | ||
where: { state: status }, |
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.
Status is optional, by default it will return all the mentors if the status is not present
src/services/admin/mentor.service.ts
Outdated
const mentors: AllMentorsArray[] = mentorsList.map((mentor, i) => { | ||
Object.entries(mentor.application).map((item) => { | ||
switchQuestion(item, applicationFormat) | ||
}) | ||
return { | ||
...mentor, | ||
mentor_id: i + 1, | ||
application: applicationFormat, | ||
category: mentor.category.category, | ||
state: mentor.state.toUpperCase() |
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.
No need for this as well. Just return the mentors
const mentors: AllMentorsArray[] = mentorsList.map((mentor, i) => { | |
Object.entries(mentor.application).map((item) => { | |
switchQuestion(item, applicationFormat) | |
}) | |
return { | |
...mentor, | |
mentor_id: i + 1, | |
application: applicationFormat, | |
category: mentor.category.category, | |
state: mentor.state.toUpperCase() |
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.
Good job! @sathudeva7
Implement Get all mentors endpoint (Admin) sef-global#24 (sef-global#67)
Purpose
The purpose of this PR is to fix #24
Goals
This issue involves implementing an API to get all mentors. The endpoint should allow Admin to make a GET request to {{baseUrl}}/api/admin/mentors?status={{status}}.
Approach