Skip to content

Overloaded GetAllMentors Function in mentor.controller.js #63

@Aditya8369

Description

@Aditya8369

Description:

The GetAllMentors function in Backend/controllers/mentor.controller.js (approximately 150 lines) manages query parsing, filtering, population, rating calculation, sorting, and response formatting. This overloads a single function with multiple responsibilities, making it prone to bugs and hard to maintain.

Proposed Solution:

Break into smaller functions: parseMentorFilters, fetchMentorProfiles, calculateMentorRatings, and sortMentors. Use a service layer for rating calculations to decouple logic.

Result:

Enhanced readability, easier unit testing of individual parts, and reduced function complexity, lowering the LOC per function and improving error isolation.

Metadata

Metadata

Assignees

Labels

No labels
No labels

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions