Changes related to the response of the Dashboard Widget for Super Admin API.

This commit is contained in:
rajesh
2025-01-15 18:03:27 +05:30
parent 60af83221e
commit 727fa506dc
3 changed files with 13 additions and 4 deletions

View File

@@ -45,9 +45,17 @@ public interface ApplicationRepository extends JpaRepository<ApplicationEntity,
@Query("SELECT a.call.id FROM ApplicationEntity a WHERE a.id = :id AND a.isDeleted = false")
Long findCallIdById(@Param("id") Long id);
@Query("SELECT a.call.name, COUNT(a.id) FROM ApplicationEntity a WHERE a.isDeleted = false AND a.call.hub.id = :hubId GROUP BY a.call.name")
@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)
List<Object[]> 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<Object[]> findApplicationsByStatus(@Param("hubId") Long hubId);