Skip to content

Commit

Permalink
fix : 정렬후 저장하지 않고 바로 바로 저장한다.
Browse files Browse the repository at this point in the history
  • Loading branch information
Due-IT committed Oct 2, 2024
1 parent 15eb6c9 commit 635800a
Showing 1 changed file with 8 additions and 7 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -56,12 +56,13 @@ public void refreshRecommendedRecipes(Long userId, RecipeCategory recipeCategory
.orElseThrow(() -> new NoSuchElementException("no user"));
List<Long> recommendedRecipeIds = aiRecipeRecommendClient.getRecommendedRecipesFromAI(recipeCategory, ingredients);
List<Recipe> recipes = recipeRepository.findAllById(recommendedRecipeIds);
List<UserRecommendedRecipe> recommendedRecipes = recipes.stream()
.map(recipe -> UserRecommendedRecipe.builder()
.user(user)
.recipe(recipe)
.build())
.collect(Collectors.toList());
recommendedRecipeRepository.saveAll(recommendedRecipes);

recipes.forEach(recipe -> {
UserRecommendedRecipe recommendedRecipe = UserRecommendedRecipe.builder()
.user(user)
.recipe(recipe)
.build();
recommendedRecipeRepository.save(recommendedRecipe);
});
}
}

0 comments on commit 635800a

Please sign in to comment.