Skip to content

Conversation

@NathanP9000
Copy link

@NathanP9000 NathanP9000 commented Sep 26, 2025

Grouping by the ids removes duplicate professors in the document

@mikehquan19
Copy link
Contributor

@NathanP9000 , can you take a look at the conflicts?

@NathanP9000
Copy link
Author

Sorry for the delay, before I finished fixing the conflicts I wanted to double check on the functionality of this endpoint and if my currently implemented fix would be acceptable.

The endpoint queries a specific course, joins its sections, and then joins the professors for each of those sections. However, one professor often teaches multiple sections, and this causes duplicate professor entries in the data stream.

When the $unwind and $replaceWith stages are executed, the professor data is fully extracted to the top level, but the original sections array from the course document is discarded. This results in a list of professors where the specific section context—which would explain the duplicates—is lost.

The Fix: My current implementation removes these duplicates to provide a clean list of unique professors. However, an alternative approach would be to refactor the pipeline to return unique combinations of professors and the specific sections they teach which would give more information than just returning the professors.

@NathanP9000 NathanP9000 changed the title added group function in pipeline to aggregate documents with the same Removing duplicates from the /course/professors endpoint Jan 15, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants