diff --git a/src/main/java/ntnu/idatt2016/v233/SmartMat/repository/RecipeRepository.java b/src/main/java/ntnu/idatt2016/v233/SmartMat/repository/RecipeRepository.java index 03ec0776aba1bb9af9185c309cd48a6955bdb306..592dabea28c767a0a5c40395579885d8865f2288 100644 --- a/src/main/java/ntnu/idatt2016/v233/SmartMat/repository/RecipeRepository.java +++ b/src/main/java/ntnu/idatt2016/v233/SmartMat/repository/RecipeRepository.java @@ -22,7 +22,13 @@ public interface RecipeRepository extends JpaRepository<Recipe, Long> { */ List<Recipe> findAllByName(String name); - + /** + * Finds the top 5 recipes with products that have a match with items in the given fridge. + * Returns a list of Object arrays, where each array contains the recipe details and product information. + * + * @param fridgeId the ID of the fridge to use for matching products + * @return a list of Object arrays with recipe and product details + */ @Query(value = """ WITH fridge_products AS ( SELECT ean diff --git a/src/main/java/ntnu/idatt2016/v233/SmartMat/service/WeeklyMenuService.java b/src/main/java/ntnu/idatt2016/v233/SmartMat/service/WeeklyMenuService.java index 823b065724909f9b52bbaafd12e434098015550f..daf9dd93586229fb14b3b9c331ef63ef6b5f115e 100644 --- a/src/main/java/ntnu/idatt2016/v233/SmartMat/service/WeeklyMenuService.java +++ b/src/main/java/ntnu/idatt2016/v233/SmartMat/service/WeeklyMenuService.java @@ -9,13 +9,23 @@ import ntnu.idatt2016.v233.SmartMat.repository.RecipeRepository; /** * Service class for weekly menu + * + * @author Stian Lyng + * @version 1.0 */ @Service public class WeeklyMenuService { @Autowired RecipeRepository recipeRepository; - + + /** + * Retrieves the top 5 recipes with products that have a match with items in the given fridge. + * Returns a list of Object arrays, where each array contains the recipe details and product information. + * + * @param groupId the ID of the fridge to use for matching products + * @return a list of Object arrays with recipe and product details + */ public List<Object[]> getTop5RecipesWithProducts(long groupId) { return recipeRepository.findTop5RecipesWithProducts(groupId); }