From 5206e3e33a906d1fad53ae44d964ecb9e38e3168 Mon Sep 17 00:00:00 2001 From: Leonardo Trevizo Date: Thu, 16 Oct 2025 11:43:57 -0600 Subject: [PATCH 1/2] Update repository query logic - Fixed logic of the query to maths the requirements. Signed-off-by: Leonardo Trevizo --- .../inventory_manager/repository/ProductRepository.java | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/main/java/com/encorazone/inventory_manager/repository/ProductRepository.java b/src/main/java/com/encorazone/inventory_manager/repository/ProductRepository.java index 551cfff..da7a811 100644 --- a/src/main/java/com/encorazone/inventory_manager/repository/ProductRepository.java +++ b/src/main/java/com/encorazone/inventory_manager/repository/ProductRepository.java @@ -15,8 +15,8 @@ public interface ProductRepository extends JpaRepository, JpaSpec @Query("SELECT DISTINCT p.category FROM Product p") Optional> findDistinctCategories(); - @Query("SELECT p.category AS category, COUNT(p) AS productsInStock, " + - "SUM(p.unitPrice) AS valueInStock, AVG(p.unitPrice) AS averageValue " + + @Query("SELECT p.category AS category, SUM(p.stockQuantity) AS productsInStock, " + + "SUM(p.unitPrice * p.stockQuantity) AS valueInStock, AVG(p.unitPrice) AS averageValue " + "FROM Product p GROUP BY p.category") List findCategoriesSummary(); } From bbcce6a46e2441dbfc5f8230959addf63cf872e7 Mon Sep 17 00:00:00 2001 From: Leonardo Trevizo Date: Thu, 16 Oct 2025 11:45:22 -0600 Subject: [PATCH 2/2] Updated show-sql setting - Updated the show-sql as theres no longer need of the logs --- src/main/resources/application.yml | 1 - 1 file changed, 1 deletion(-) diff --git a/src/main/resources/application.yml b/src/main/resources/application.yml index ad1d987..f6a63d8 100644 --- a/src/main/resources/application.yml +++ b/src/main/resources/application.yml @@ -18,4 +18,3 @@ spring: jpa: hibernate: ddl-auto: update - show-sql: true