Skip to content

Swipehistory#168

Merged
zakkiyyat merged 5 commits intoMixMatch-Inc:mainfrom
nurudeenmuzainat:swipehistory
Mar 7, 2026
Merged

Swipehistory#168
zakkiyyat merged 5 commits intoMixMatch-Inc:mainfrom
nurudeenmuzainat:swipehistory

Conversation

@nurudeenmuzainat
Copy link
Contributor

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 (like or pass), and timestamp, along with a compound index on { user_id: 1, food_id: 1 } to optimize lookup performance. The GET /api/foods/discover endpoint is updated to filter out previously swiped food items by retrieving the user’s swipe history and excluding those food_id values 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

Copy link
Contributor

@zakkiyyat zakkiyyat left a comment

Choose a reason for hiding this comment

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

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 })
: []

Copy link
Contributor

Choose a reason for hiding this comment

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

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
Copy link
Contributor

@zakkiyyat zakkiyyat left a comment

Choose a reason for hiding this comment

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

Please fix the merge conflicts with the target branch and we can proceed with the merge.

@nurudeenmuzainat
Copy link
Contributor Author

all done @zakkiyyat

Copy link
Contributor

@zakkiyyat zakkiyyat left a comment

Choose a reason for hiding this comment

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

Everything looks good now, approving.

@zakkiyyat zakkiyyat merged commit e66f060 into MixMatch-Inc:main Mar 7, 2026
1 check passed
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.

Swipe History & Duplicate Prevention

2 participants