-
Notifications
You must be signed in to change notification settings - Fork 1
[FIX] 나의 출석 현황 리스트 조회 오류를 해결합니다. #244
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
Conversation
Walkthrough이번 PR은 나의 출석 현황 조회 기능을 개선합니다.
Changes
Sequence Diagram(s)sequenceDiagram
participant C as Client
participant S as AttendService
participant AR as AttendRepository (Persistence)
participant PR as ProgramRepository
C->>S: findMyAttendInfo(memberId, startDate, endDate)
S->>AR: findAllByMemberIdAndCreatedDateGreaterThan(memberId, startDate, endDate, pageable)
AR-->>S: Page<AttendEntity>
S->>PR: 매핑을 위해 ProgramModel 조회 (각 AttendEntity에 대해)
PR-->>S: ProgramModel 반환
S-->>C: AttendInfoWithProgramResponse (페이징 포함)
Assessment against linked issues
Suggested reviewers
Poem
✨ Finishing Touches
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. 🪧 TipsChatThere are 3 ways to chat with CodeRabbit:
Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments. CodeRabbit Commands (Invoked using PR comments)
Other keywords and placeholders
CodeRabbit Configuration File (
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Actionable comments posted: 0
🧹 Nitpick comments (2)
eeos/src/main/java/com/blackcompany/eeos/target/persistence/AttendRepository.java (1)
61-67: 쿼리 구현이 적절히 작성되었습니다.메소드 및 쿼리 구현이 회원 ID와 날짜 범위를 기준으로 출석 기록을 페이징하여 조회하는 요구사항을 잘 충족합니다. 다만, 메소드 이름과 실제 동작이 약간 불일치합니다.
메소드 이름
findAllByMemberIdAndCreatedDateGreaterThan은createdDate > startDate만 검사하는 것처럼 보이지만, 실제 쿼리는 날짜 범위(startDate < createdDate < endDate)를 검사합니다. 다음과 같이 메소드 이름을 더 명확하게 수정하는 것을 고려해보세요:-Page<AttendEntity> findAllByMemberIdAndCreatedDateGreaterThan( +Page<AttendEntity> findAllByMemberIdAndCreatedDateBetween( @Param("memberId") Long memberId, @Param("startDate") Timestamp startDate, @Param("endDate") Timestamp endDate, Pageable pageable);eeos/src/main/java/com/blackcompany/eeos/target/application/service/AttendService.java (1)
226-244: 코드가 개선되었으나 최적화 가능성이 있습니다.기존 프로그램 기반 조회에서 직접 사용자의 출석 기록을 조회하는 방식으로 변경하여 문제를 해결했습니다. 그러나 각 출석 기록마다 개별적으로 프로그램 정보를 조회하는 방식은 N+1 쿼리 문제를 발생시킬 수 있습니다.
다음과 같이 프로그램 정보를 한 번에 조회하여 성능을 개선할 수 있습니다:
if (!myAttend.isEmpty()) { + // 프로그램 ID 목록 추출 + List<Long> programIds = myAttend.stream() + .map(AttendEntity::getProgramId) + .distinct() + .toList(); + + // 프로그램 정보를 한 번에 조회하여 맵으로 변환 + Map<Long, ProgramModel> programMap = programRepository.findAllById(programIds).stream() + .map(programEntityConverter::from) + .collect(Collectors.toMap(ProgramModel::getId, program -> program)); + responses = new PageImpl<>( myAttend.stream() .map(attendEntityConverter::from) .map( attendModel -> { - ProgramModel program = - programRepository - .findById(attendModel.getProgramId()) - .map(programEntityConverter::from) - .orElse(null); + ProgramModel program = programMap.get(attendModel.getProgramId()); if (program == null) return null; return attendInfoWithProgramConverter.from(attendModel, program); }) .filter(Objects::nonNull) .toList(), myAttend.getPageable(), myAttend.getTotalElements());
📜 Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro
📒 Files selected for processing (3)
eeos/src/main/java/com/blackcompany/eeos/target/application/repository/AttendRepository.java(2 hunks)eeos/src/main/java/com/blackcompany/eeos/target/application/service/AttendService.java(1 hunks)eeos/src/main/java/com/blackcompany/eeos/target/persistence/AttendRepository.java(2 hunks)
🔇 Additional comments (2)
eeos/src/main/java/com/blackcompany/eeos/target/application/repository/AttendRepository.java (1)
32-33: 추가된 메소드가 요구사항과 잘 부합합니다.새로 추가된
findMyAttendList메소드는 사용자 ID와 날짜 범위를 기반으로 출석 목록을 조회하는 기능을 제공하여 PR의 목적인 "나의 출석 현황 리스트 조회 오류 해결"에 적절합니다.eeos/src/main/java/com/blackcompany/eeos/target/application/service/AttendService.java (1)
216-222: 페이징 및 정렬 구현이 적절합니다.나의 출석 현황을 최신순(생성일자 내림차순)으로 정렬하고 페이징하는 기능이 잘 구현되었습니다.
📌 관련 이슈
closes #243
✒️ 작업 내용
스크린샷 🏞️ (선택)
💬 REVIEWER에게 요구사항 💬
Summary by CodeRabbit