Skip to content

Commit

Permalink
Fix: 지원서 통계데이터 조회 쿼리 수정
Browse files Browse the repository at this point in the history
  • Loading branch information
kwonssshyeon committed Aug 19, 2024
1 parent fc6014c commit 7ed8aeb
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -4,4 +4,5 @@ public interface ApplicationStatisticType {
Integer getTotal();
Integer getOpenCount();
Integer getApprovedCount();
Integer getRejectedCount();
}
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,9 @@ public interface ApplicationRepository extends JpaRepository<Application, Long>,

@Query("SELECT " +
"COUNT(CASE WHEN a.applicationStatus != 'TEMPORAL' THEN 1 END) AS total, " +
"COUNT(CASE WHEN a.isOpened = true THEN 1 END) AS openCount, " +
"COUNT(CASE WHEN a.applicationStatus = 'APPROVED' THEN 1 END) AS approvedCount " +
"COUNT(CASE WHEN a.isOpened = true AND a.applicationStatus != 'TEMPORAL' THEN 1 END) AS openCount, " +
"COUNT(CASE WHEN a.applicationStatus = 'APPROVED' THEN 1 END) AS approvedCount, " +
"COUNT(CASE WHEN a.applicationStatus = 'REJECTED' THEN 1 END) AS rejectedCount " +
"FROM Application a")
ApplicationStatisticType getStatistics();

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,12 +25,13 @@ public class AdminApplicationService {
@Transactional(readOnly = true)
public AdminApplicationResponse.Statistics getStatistic() {
ApplicationStatisticType statistic = applicationRepository.getStatistics();
//TODO: Builder를 바로 사용하는게 가독성 좋을거 같음
return AdminApplicationResponse.Statistics.of(
statistic.getTotal(),
statistic.getOpenCount(),
statistic.getTotal() - statistic.getOpenCount(),
statistic.getApprovedCount(),
statistic.getTotal() - statistic.getApprovedCount());
statistic.getRejectedCount());
}


Expand Down

0 comments on commit 7ed8aeb

Please sign in to comment.