Merged
Conversation
zakkiyyat
requested changes
Mar 7, 2026
Contributor
zakkiyyat
left a comment
There was a problem hiding this comment.
Please fix the merge conflicts with the target branch and we can proceed with the merge.
Comment on lines
+48
to
+51
| const swipedFoodIds = query.user_id | ||
| ? await UserSwipeModel.distinct("food_id", { user_id: query.user_id }) | ||
| : [] | ||
|
|
Contributor
There was a problem hiding this comment.
user_id must be a valid Mongo ObjectId before querying UserSwipe, please fix the discovery swipe-filter implementation for correctness and safety with emphasis on
- validation and sanitization of user_id query input
- correctness of $nin filtering against swiped food_id values
- index usage and query scalability for UserSwipe lookups
- behavior when user_id is malformed or absent.
# Conflicts: # backend/README.md # backend/src/models/food-item.model.ts # backend/src/models/index.ts # backend/src/models/user-swipe.model.ts # backend/src/routes/index.ts
zakkiyyat
requested changes
Mar 7, 2026
Contributor
zakkiyyat
left a comment
There was a problem hiding this comment.
Please fix the merge conflicts with the target branch and we can proceed with the merge.
Contributor
Author
|
all done @zakkiyyat |
zakkiyyat
approved these changes
Mar 7, 2026
Contributor
zakkiyyat
left a comment
There was a problem hiding this comment.
Everything looks good now, approving.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Adds swipe history tracking so users are not shown food items they have already interacted with. A UserSwipe MongoDB schema is created with the fields
user_id,food_id,action(likeorpass), andtimestamp, along with a compound index on{ user_id: 1, food_id: 1 }to optimize lookup performance. TheGET /api/foods/discoverendpoint is updated to filter out previously swiped food items by retrieving the user’s swipe history and excluding thosefood_idvalues from the discovery query using MongoDB$nin(or$lookup). This ensures the discovery feed only returns new, unseen food items while maintaining efficient database queries.closes #151