-
Notifications
You must be signed in to change notification settings - Fork 1
[FEAT] 전체 회원의 출석 통계 API 구현 #286
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from 8 commits
9b1c9d6
4957601
e6f0542
7e27fc7
88de19f
a806738
e6986ea
367ebbb
0dbca58
64a3207
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,18 @@ | ||
| package com.blackcompany.eeos.target.application.dto; | ||
|
|
||
| import com.blackcompany.eeos.common.support.dto.AbstractResponseDto; | ||
| import java.util.List; | ||
|
|
||
| public record AttendStatisticsResponse( | ||
| List<MemberStatistics> members | ||
| ) implements AbstractResponseDto { | ||
|
|
||
| public record MemberStatistics( | ||
| Long id, | ||
| String name, | ||
| String activeStatus, | ||
| int lateCount, | ||
| int absentCount, | ||
| int penaltyPoint | ||
| ){} | ||
| } |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -40,4 +40,5 @@ Page<Object[]> findByPenaltyPointSum( | |
| @Query( | ||
| "SELECT temp.memberId, temp.totalScore FROM (SELECT a.memberId as memberId, SUM(a.penaltyScore) as totalScore FROM AttendEntity a GROUP BY a.memberId) AS temp") | ||
| Page<Object[]> findByPenaltyPointSum(Pageable pageable); | ||
|
Comment on lines
40
to
42
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 🧩 Analysis chainJPQL FROM 서브쿼리 + Page 카운트/정렬 이슈 — JPQL로 재작성하고 countQuery/ORDER BY 추가 필요
아래처럼 JPQL로 평탄화 + countQuery + 안정적 ORDER BY를 추가해 주세요. - @Query(
- "SELECT temp.memberId, temp.totalScore FROM (SELECT a.memberId as memberId, SUM(a.penaltyScore) as totalScore FROM AttendEntity a GROUP BY a.memberId) AS temp")
- Page<Object[]> findByPenaltyPointSum(Pageable pageable);
+ @Query(
+ value = "SELECT a.memberId, SUM(a.penaltyScore) FROM AttendEntity a GROUP BY a.memberId ORDER BY SUM(a.penaltyScore) DESC",
+ countQuery = "SELECT COUNT(DISTINCT a.memberId) FROM AttendEntity a")
+ Page<Object[]> findByPenaltyPointSum(Pageable pageable);참고: 동일한 문제 패턴(서브쿼리/페이징)이 있는 기간 제한 오버로드(findByPenaltyPointSum(startDate, endDate, Pageable))에도 동일한 형태로 적용해 주세요. 🏁 Script executed: #!/bin/bash
set -euo pipefail
echo "== repo files matching PenaltyPointRepository =="
rg -n --hidden --no-ignore 'PenaltyPointRepository' || true
echo
echo "== show file content =="
sed -n '1,240p' eeos/src/main/java/com/blackcompany/eeos/target/persistence/PenaltyPointRepository.java || true
echo
echo "== find usages of findByPenaltyPointSum =="
rg -n --hidden --no-ignore 'findByPenaltyPointSum' || true
echo
echo "== show other repository files in same package =="
ls -1 eeos/src/main/java/com/blackcompany/eeos/target/persistence || trueLength of output: 3577 JPQL FROM 서브쿼리 사용 제거·페이징/카운트 안정화 (즉시 수정 필요)
제안된 변경(예시) @Query(
value = "SELECT a.memberId, SUM(a.penaltyScore) FROM AttendEntity a GROUP BY a.memberId ORDER BY SUM(a.penaltyScore) DESC",
countQuery = "SELECT COUNT(DISTINCT a.memberId) FROM AttendEntity a")
Page<Object[]> findByPenaltyPointSum(Pageable pageable);
@Query(
value = "SELECT a.memberId, SUM(a.penaltyScore) FROM AttendEntity a WHERE a.createdDate >= :startDate AND a.createdDate <= :endDate GROUP BY a.memberId ORDER BY SUM(a.penaltyScore) DESC",
countQuery = "SELECT COUNT(DISTINCT a.memberId) FROM AttendEntity a WHERE a.createdDate >= :startDate AND a.createdDate <= :endDate")
Page<Object[]> findByPenaltyPointSum(
@Param("startDate") Timestamp startDate,
@Param("endDate") Timestamp endDate,
Pageable pageable);
행 단위 카운트 예시: @Query("SELECT COUNT(a) FROM AttendEntity a WHERE a.createdDate >= :startDate AND a.createdDate <= :endDate AND a.penaltyScore = :penaltyPoint")
Long countByPenaltyPoint(...);
@Query("SELECT COUNT(a) FROM AttendEntity a WHERE a.createdDate >= :startDate AND a.createdDate <= :endDate AND a.penaltyScore > :penaltyPoint")
Long countByPenaltyPointGreaterThan(...);파일: eeos/src/main/java/com/blackcompany/eeos/target/persistence/PenaltyPointRepository.java — 위 항목들 즉시 수정 필요. 🤖 Prompt for AI Agents |
||
|
|
||
| } | ||
Uh oh!
There was an error while loading. Please reload this page.