Skip to content

Commit

Permalink
fixe recomendation dublication
Browse files Browse the repository at this point in the history
  • Loading branch information
VovaStelmashchuk committed Sep 28, 2024
1 parent a3a1c7b commit 8c7e426
Showing 1 changed file with 2 additions and 1 deletion.
3 changes: 2 additions & 1 deletion features/cocktail/utils.js
Original file line number Diff line number Diff line change
Expand Up @@ -17,11 +17,12 @@ async function getRecommendations(cocktail) {

for (const slugs of classCocktailSlugs) {
if (recommendationCocktails.length >= maxRecommendations) break;
const slugsWithoutExist = slugs.filter(slug => !recommendationCocktails.some(cocktail => cocktail.slug === slug));

const countToFull = maxRecommendations - recommendationCocktails.length;

const classCocktails = await Database.collection('cocktails')
.find({ slug: { $in: slugs } })
.find({ slug: { $in: slugsWithoutExist } })
.sort({ visitCount: -1 })
.limit(countToFull)
.project({ _id: 0, id: 1, slug: 1, name: 1, ratingCount: 1, ratingValue: 1, visitCount: 1 })
Expand Down

0 comments on commit 8c7e426

Please sign in to comment.