From 1b6a11a7710093845b6a22d0635957d613bd848a Mon Sep 17 00:00:00 2001 From: nisha Date: Wed, 15 Jan 2025 19:49:09 +0530 Subject: [PATCH] Updated JPA query of dashboard --- .../repositories/ApplicationRepository.java | 18 +++++++++++++----- 1 file changed, 13 insertions(+), 5 deletions(-) diff --git a/src/main/java/net/gepafin/tendermanagement/repositories/ApplicationRepository.java b/src/main/java/net/gepafin/tendermanagement/repositories/ApplicationRepository.java index 5bac8a89..086b0807 100644 --- a/src/main/java/net/gepafin/tendermanagement/repositories/ApplicationRepository.java +++ b/src/main/java/net/gepafin/tendermanagement/repositories/ApplicationRepository.java @@ -45,17 +45,25 @@ public interface ApplicationRepository extends JpaRepository findApplicationsPerCallWithName(@Param("hubId") Long hubId); + @Query(value = "SELECT c.name AS callName, " + "SUM(CASE WHEN a.status IN ('DISCARD', 'SOCCORSO', 'APPROVED', 'REJECTED', 'EVALUATION', 'APPOINTMENT', 'NDG', 'ADMISSIBLE', 'SUBMIT') THEN 1 ELSE 0 END) AS totalApplications, " + "SUM(CASE WHEN a.status IN ('DRAFT', 'AWAITING', 'READY') THEN 1 ELSE 0 END) AS draftApplications " + - "FROM application a " + - "JOIN call c ON a.call_id = c.id " + - "WHERE a.is_deleted = false AND c.hub_id = :hubId " + - "GROUP BY c.name", nativeQuery = true) + "FROM ApplicationEntity a " + + "JOIN a.call c " + + "WHERE a.isDeleted = false AND c.hub.id = :hubId " + + "GROUP BY c.name") List findApplicationsPerCallWithName(@Param("hubId") Long hubId); - // Count Applications by Status by Hub ID @Query("SELECT a.status, COUNT(a.id) FROM ApplicationEntity a WHERE a.isDeleted = false AND a.call.hub.id = :hubId GROUP BY a.status") List findApplicationsByStatus(@Param("hubId") Long hubId);