stack_overflow_nextjs14 icon indicating copy to clipboard operation
stack_overflow_nextjs14 copied to clipboard

fix: return user tags interactions

Open mohannadofficial opened this issue 1 year ago • 1 comments

Remove Static return list and implement dynamic user tags interactions

Static Data return [ {_id: '1', name: 'tag'}, {_id: '2', name: 'tag2'}] replace with


    // Find the user's interactions where actions equal "ask_question" or "answer" and return tags name without duplicates
    const userInteractions = await Interaction.find({
      user: user._id,
      action: { $in: ["ask_question", "answer"] },
    }).distinct("tags");

    // Extract tags from user's interactions limited to 5 tags
    const tags = await Tag.find({ _id: { $in: userInteractions } }).limit(5);
    // return list of tags
    return tags;

mohannadofficial avatar May 18 '24 14:05 mohannadofficial

@mohannadofficial is attempting to deploy a commit to the JS Mastery Pro Team on Vercel.

A member of the Team first needs to authorize it.

vercel[bot] avatar May 18 '24 14:05 vercel[bot]