Skip to content

Conversation

@rlajm1203
Copy link
Contributor

@rlajm1203 rlajm1203 commented Mar 26, 2025

📌 관련 이슈

closes #243

✒️ 작업 내용

  • 출석 리스트를 조회할 때, 전체 Program 데이터를 기준으로 조회하여, pageInfo (전체 페이지 수, 한 페이지 당 사이즈 등) 가 전체 Program 데이터를 기준으로 조회가 되는 경우가 발생했습니다.
  • 전체 Program 데이터가 아닌, 나의 attend 데이터를 기준으로 조회하여 오류를 수정합니다.

스크린샷 🏞️ (선택)

💬 REVIEWER에게 요구사항 💬

Summary by CodeRabbit

  • 새로운 기능
    • 특정 멤버의 출석 기록을 지정 기간 내에 조회할 수 있도록 기능이 확장되었습니다.
    • 출석 정보 조회 로직이 개선되어, 페이징 처리와 응답 구성이 더욱 효율적으로 변경되었습니다.

@rlajm1203 rlajm1203 added the bug Something isn't working label Mar 26, 2025
@rlajm1203 rlajm1203 requested a review from kssumin March 26, 2025 16:51
@rlajm1203 rlajm1203 self-assigned this Mar 26, 2025
@coderabbitai
Copy link

coderabbitai bot commented Mar 26, 2025

Walkthrough

이번 PR은 나의 출석 현황 조회 기능을 개선합니다.

  • AttendRepository (application) 에 새로운 메소드 findMyAttendList(Long, LocalDateTime, LocalDateTime)를 추가하여 회원의 특정 기간 내 출석 기록을 조회합니다.
  • AttendServicefindMyAttendInfo 메소드가 수정되어, 기존 프로그램 기반 조회 로직 대신 새로 도입된 페이징 및 날짜 필터링 메소드를 통해 출석 데이터를 직접 조회하고 응답을 구성합니다.
  • AttendRepository (persistence) 에서는 페이징 지원과 날짜 기반 필터링을 위한 findAllByMemberIdAndCreatedDateGreaterThan 메소드가 추가되었습니다.

Changes

파일 변경 사항
eeos/.../application/repository/AttendRepository.java 새로운 메소드 findMyAttendList(Long, LocalDateTime, LocalDateTime)가 추가됨.
eeos/.../application/service/AttendService.java findMyAttendInfo 메소드가 수정되어, 출석 데이터를 직접 조회하고 응답 매핑 로직이 변경됨.
eeos/.../persistence/AttendRepository.java 새로운 메소드 findAllByMemberIdAndCreatedDateGreaterThan(Long, Timestamp, Timestamp, Pageable)가 추가되어 페이징 및 날짜 필터링 지원.

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 (페이징 포함)
Loading

Assessment against linked issues

Objective (이슈) Addressed Explanation
나의 출석 현황 리스트 조회 오류 수정 (#243)

Suggested reviewers

  • Daae-Kim
  • kssumin

Poem

저는 귀여운 토끼에요, 코딩 숲을 뛰놀며
출석 기록이 춤추듯 정리되는 걸 보네 🐇
새로운 메소드 꽃피듯 피어나고,
서비스 로직도 깡충깡충 도약해요,
이번 변화에 모두가 미소 짓길 바래요!
🌼✨

✨ Finishing Touches
  • 📝 Generate Docstrings

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.

❤️ Share
🪧 Tips

Chat

There are 3 ways to chat with CodeRabbit:

  • Review comments: Directly reply to a review comment made by CodeRabbit. Example:
    • I pushed a fix in commit <commit_id>, please review it.
    • Generate unit testing code for this file.
    • Open a follow-up GitHub issue for this discussion.
  • Files and specific lines of code (under the "Files changed" tab): Tag @coderabbitai in a new review comment at the desired location with your query. Examples:
    • @coderabbitai generate unit testing code for this file.
    • @coderabbitai modularize this function.
  • PR comments: Tag @coderabbitai in a new PR comment to ask questions about the PR branch. For the best results, please provide a very specific query, as very limited context is provided in this mode. Examples:
    • @coderabbitai gather interesting stats about this repository and render them as a table. Additionally, render a pie chart showing the language distribution in the codebase.
    • @coderabbitai read src/utils.ts and generate unit testing code.
    • @coderabbitai read the files in the src/scheduler package and generate a class diagram using mermaid and a README in the markdown format.
    • @coderabbitai help me debug CodeRabbit configuration file.

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)

  • @coderabbitai pause to pause the reviews on a PR.
  • @coderabbitai resume to resume the paused reviews.
  • @coderabbitai review to trigger an incremental review. This is useful when automatic reviews are disabled for the repository.
  • @coderabbitai full review to do a full review from scratch and review all the files again.
  • @coderabbitai summary to regenerate the summary of the PR.
  • @coderabbitai generate docstrings to generate docstrings for this PR.
  • @coderabbitai resolve resolve all the CodeRabbit review comments.
  • @coderabbitai plan to trigger planning for file edits and PR creation.
  • @coderabbitai configuration to show the current CodeRabbit configuration for the repository.
  • @coderabbitai help to get help.

Other keywords and placeholders

  • Add @coderabbitai ignore anywhere in the PR description to prevent this PR from being reviewed.
  • Add @coderabbitai summary to generate the high-level summary at a specific location in the PR description.
  • Add @coderabbitai anywhere in the PR title to generate the title automatically.

CodeRabbit Configuration File (.coderabbit.yaml)

  • You can programmatically configure CodeRabbit by adding a .coderabbit.yaml file to the root of your repository.
  • Please see the configuration documentation for more information.
  • If your editor has YAML language server enabled, you can add the path at the top of this file to enable auto-completion and validation: # yaml-language-server: $schema=https://coderabbit.ai/integrations/schema.v2.json

Documentation and Community

  • Visit our Documentation for detailed information on how to use CodeRabbit.
  • Join our Discord Community to get help, request features, and share feedback.
  • Follow us on X/Twitter for updates and announcements.

@rlajm1203 rlajm1203 requested a review from Daae-Kim March 26, 2025 16:52
@github-actions
Copy link

Test Results

89 tests  ±0   86 ✅ ±0   4s ⏱️ ±0s
35 suites ±0    3 💤 ±0 
35 files   ±0    0 ❌ ±0 

Results for commit ab8f9c0. ± Comparison against base commit 8d2efe3.

Copy link

@coderabbitai coderabbitai bot left a 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와 날짜 범위를 기준으로 출석 기록을 페이징하여 조회하는 요구사항을 잘 충족합니다. 다만, 메소드 이름과 실제 동작이 약간 불일치합니다.

메소드 이름 findAllByMemberIdAndCreatedDateGreaterThancreatedDate > 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

📥 Commits

Reviewing files that changed from the base of the PR and between 8d2efe3 and ab8f9c0.

📒 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: 페이징 및 정렬 구현이 적절합니다.

나의 출석 현황을 최신순(생성일자 내림차순)으로 정렬하고 페이징하는 기능이 잘 구현되었습니다.

@rlajm1203 rlajm1203 merged commit 4306091 into develop Mar 26, 2025
4 checks passed
@rlajm1203 rlajm1203 deleted the BM/fix/#243/attend-list branch March 26, 2025 16:57
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug Something isn't working

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[FIX] 나의 출석 현황 리스트 조회 오류를 해결합니다.

2 participants