Skip to content
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

feat: 스터디 주차별 출결번호 조회 #688

Merged
merged 5 commits into from
Aug 26, 2024

Conversation

seulgi99
Copy link
Contributor

@seulgi99 seulgi99 commented Aug 26, 2024

🌱 관련 이슈

📌 작업 내용 및 특이사항

  • 멘토용 스터디 출결번호 목록 조회 API 입니다.

📝 참고사항

📚 기타

Summary by CodeRabbit

  • New Features

    • 멘토가 특정 스터디의 출석 기록을 조회할 수 있는 새로운 API 엔드포인트 추가.
    • 출석 정보를 포함하는 StudyMentorAttendanceResponse 객체를 반환하는 메서드 추가.
    • 출석일이 지났는지 여부를 확인할 수 있는 메서드 추가.
  • Documentation

    • API 문서화를 위한 메타데이터 추가.

@seulgi99 seulgi99 added the ✨ feature 새로운 기능 추가 및 수정 label Aug 26, 2024
@seulgi99 seulgi99 self-assigned this Aug 26, 2024
@seulgi99 seulgi99 requested a review from a team as a code owner August 26, 2024 02:48
Copy link

coderabbitai bot commented Aug 26, 2024

Walkthrough

변경 사항은 MentorStudyDetailControllerMentorStudyDetailService 클래스에 출결 번호를 조회하는 새로운 메서드를 추가합니다. 이 메서드는 특정 studyId에 대한 출결 정보를 반환하며, 새로운 DTO인 StudyMentorAttendanceResponse를 통해 응답 구조를 정의합니다. 또한, StudyDetail 클래스에 출결일을 확인하는 메서드가 추가되었습니다. 이로 인해 멘토는 스터디의 출결 기록을 조회할 수 있는 기능이 추가되었습니다.

Changes

파일 경로 변경 요약
src/main/java/com/gdschongik/gdsc/domain/study/api/MentorStudyDetailController.java
src/main/java/com/gdschongik/gdsc/domain/study/application/MentorStudyDetailService.java
getAttendanceNumbers 메서드 추가: 스터디 ID에 따른 출결 번호 조회 기능 구현.
src/main/java/com/gdschongik/gdsc/domain/study/domain/StudyDetail.java isAttendanceDayPassedisAttendanceDayNotPassed 메서드 추가: 출결일 확인 기능 구현.

Sequence Diagram(s)

sequenceDiagram
    participant Mentor
    participant Controller
    participant Service
    participant Repository

    Mentor->>Controller: 출결 번호 요청 (studyId)
    Controller->>Service: getAttendanceNumbers(studyId)
    Service->>Repository: 스터디 세부 정보 조회 (studyId)
    Repository-->>Service: 스터디 세부 정보 반환
    Service-->>Controller: 출결 번호 리스트 반환
    Controller-->>Mentor: 출결 번호 응답
Loading

Assessment against linked issues

Objective Addressed Explanation
스터디 멘토 주차별 출결번호 조회 API 추가 (#687)

🐰 새로운 기능이 생겼어요,
멘토가 출결을 쉽게 알 수 있어요.
스터디의 세부 정보가 쏙쏙,
출결 번호도 한눈에 쏙!
모두 함께 기뻐해요,
Rabbit의 춤을 춰요! 🎉


Thank you for using CodeRabbit. We offer it for free to the OSS community and would appreciate your support in helping us grow. If you find it useful, would you consider giving us a shout-out on your favorite social media?

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>.
    • 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 generate interesting stats about this repository and render them as a table.
    • @coderabbitai show all the console.log statements in this repository.
    • @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 as 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 resolve resolve all the CodeRabbit review comments.
  • @coderabbitai configuration to show the current CodeRabbit configuration for the repository.
  • @coderabbitai help to get help.

Additionally, you can add @coderabbitai ignore anywhere in the PR description to prevent this PR from being reviewed.

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.

Copy link

Job Summary for Gradle

Check Style and Test to Develop :: build-test
Gradle Root Project Requested Tasks Gradle Version Build Outcome Build Scan®
gdsc check 8.5 Build Scan published

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

Review details

Configuration used: CodeRabbit UI
Review profile: CHILL

Commits

Files that changed from the base of the PR and between 2ee4399 and 899d0b4.

Files selected for processing (3)
  • src/main/java/com/gdschongik/gdsc/domain/study/api/MentorStudyDetailController.java (2 hunks)
  • src/main/java/com/gdschongik/gdsc/domain/study/application/MentorStudyDetailService.java (2 hunks)
  • src/main/java/com/gdschongik/gdsc/domain/study/dto/response/StudyMentorAttendanceResponse.java (1 hunks)
Additional comments not posted (6)
src/main/java/com/gdschongik/gdsc/domain/study/dto/response/StudyMentorAttendanceResponse.java (4)

1-1: 패키지 선언 확인

패키지 선언이 적절합니다.

코드 변경 사항이 승인되었습니다.


3-5: 필수 import 확인

필수 import가 적절하게 포함되어 있습니다.

코드 변경 사항이 승인되었습니다.


7-11: 레코드 필드 선언 확인

레코드 필드 선언이 적절하며, @Schema 어노테이션을 사용하여 API 문서화를 돕고 있습니다.

코드 변경 사항이 승인되었습니다.


12-18: 정적 메서드 from 구현 확인

정적 메서드 fromStudyDetail 객체를 StudyMentorAttendanceResponse 객체로 변환하는 로직이 적절합니다.

코드 변경 사항이 승인되었습니다.

src/main/java/com/gdschongik/gdsc/domain/study/api/MentorStudyDetailController.java (1)

76-82: 새로운 엔드포인트 메서드 추가 확인

새로운 엔드포인트 메서드 getAttendanceNumber가 적절하게 추가되었습니다. @Operation 어노테이션을 사용하여 API 문서화를 돕고 있으며, studyId를 요청 파라미터로 받아 출결 번호 목록을 반환합니다.

코드 변경 사항이 승인되었습니다.

src/main/java/com/gdschongik/gdsc/domain/study/application/MentorStudyDetailService.java (1)

96-107: 새로운 메서드 추가 확인

새로운 메서드 getAttendanceNumber가 적절하게 추가되었습니다. @Transactional(readOnly = true) 어노테이션을 사용하여 읽기 전용 트랜잭션을 보장하며, 주어진 studyId에 대한 출결 정보를 적절히 필터링하여 반환합니다.

코드 변경 사항이 승인되었습니다.

Copy link

Job Summary for Gradle

Check Style and Test to Develop :: build-test
Gradle Root Project Requested Tasks Gradle Version Build Outcome Build Scan®
gdsc check 8.5 Build Scan published

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

Review details

Configuration used: CodeRabbit UI
Review profile: CHILL

Commits

Files that changed from the base of the PR and between 899d0b4 and 3d29b99.

Files selected for processing (1)
  • src/main/java/com/gdschongik/gdsc/domain/study/api/MentorStudyDetailController.java (2 hunks)
Files skipped from review as they are similar to previous changes (1)
  • src/main/java/com/gdschongik/gdsc/domain/study/api/MentorStudyDetailController.java

Copy link
Member

@AlmondBreez3 AlmondBreez3 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

lgtm

Copy link
Member

@Sangwook02 Sangwook02 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

메서드명 수정 부탁드려요!
++ 하나 제안 사항도 있습니다~

Copy link

Job Summary for Gradle

Check Style and Test to Develop :: build-test
Gradle Root Project Requested Tasks Gradle Version Build Outcome Build Scan®
gdsc check 8.5 Build Scan published

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

Review details

Configuration used: CodeRabbit UI
Review profile: CHILL

Commits

Files that changed from the base of the PR and between 3d29b99 and 4a5f3d3.

Files selected for processing (3)
  • src/main/java/com/gdschongik/gdsc/domain/study/api/MentorStudyDetailController.java (2 hunks)
  • src/main/java/com/gdschongik/gdsc/domain/study/application/MentorStudyDetailService.java (2 hunks)
  • src/main/java/com/gdschongik/gdsc/domain/study/domain/StudyDetail.java (1 hunks)
Additional comments not posted (3)
src/main/java/com/gdschongik/gdsc/domain/study/api/MentorStudyDetailController.java (1)

76-82: 코드 검토 완료: 출결번호 조회 API 추가

getAttendanceNumbers 메서드는 올바르게 구현되었습니다. 예외 처리와 엣지 케이스를 잘 다루고 있는지 확인하시기 바랍니다.

코드 변경 사항이 승인되었습니다.

src/main/java/com/gdschongik/gdsc/domain/study/application/MentorStudyDetailService.java (1)

96-105: 코드 검토 완료: 출결번호 조회 서비스 메서드 추가

getAttendanceNumbers 메서드는 올바르게 구현되었습니다. 예외 처리와 엣지 케이스를 잘 다루고 있는지 확인하시기 바랍니다.

코드 변경 사항이 승인되었습니다.

src/main/java/com/gdschongik/gdsc/domain/study/domain/StudyDetail.java (1)

126-129: 코드 검토 완료: 출석일 확인 메서드 추가

isAttendanceDayPassed 메서드는 올바르게 구현되었습니다. 예외 처리와 엣지 케이스를 잘 다루고 있는지 확인하시기 바랍니다.

코드 변경 사항이 승인되었습니다.

Copy link
Member

@Sangwook02 Sangwook02 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

미리 approve 남겨요!
같이 남긴 코멘트 확인해주세요!

@@ -123,6 +123,11 @@ public LocalDate getAttendanceDay() {
return startDate.plusDays(daysToAdd);
}

// 출석일이 오늘 or 오늘이후인지 확인
public boolean isAttendanceDayPassed(LocalDate now) {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

엄밀히 따지자면 isAttendanceDayNotPassed가 맞는 것 같습니다.

++ now를 메서드에서 직접 호출하지 않는 이유가 있나요?
메서드 참조를 활용하면 좋을 것 같아서요!

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

네 메소드 명은 변경하겠습니다.

now를 받도록 한 이유는 추후 다른 테스트 or 로직에서 사용하게 될떄 테스트할때 용이하도록 하기 위해서 이렇게 한거에요!!

Copy link

Job Summary for Gradle

Check Style and Test to Develop :: build-test
Gradle Root Project Requested Tasks Gradle Version Build Outcome Build Scan®
gdsc check 8.5 Build Scan published

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: 1

Outside diff range, codebase verification and nitpick comments (1)
src/main/java/com/gdschongik/gdsc/domain/study/application/MentorStudyDetailService.java (1)

96-105: 메서드 이름을 더 설명적으로 변경하세요.

getAttendanceNumbers라는 이름은 이 메서드가 정확히 무엇을 하는지 명확하지 않습니다. 예를 들어, getFutureAttendanceNumbers 또는 getUpcomingAttendanceNumbers와 같은 이름이 더 적절할 수 있습니다.

Review details

Configuration used: CodeRabbit UI
Review profile: CHILL

Commits

Files that changed from the base of the PR and between 4a5f3d3 and 2c3f663.

Files selected for processing (2)
  • src/main/java/com/gdschongik/gdsc/domain/study/application/MentorStudyDetailService.java (2 hunks)
  • src/main/java/com/gdschongik/gdsc/domain/study/domain/StudyDetail.java (1 hunks)
Files skipped from review as they are similar to previous changes (1)
  • src/main/java/com/gdschongik/gdsc/domain/study/domain/StudyDetail.java
Additional comments not posted (1)
src/main/java/com/gdschongik/gdsc/domain/study/application/MentorStudyDetailService.java (1)

100-102: 필터링 로직을 StudyDetail 엔티티로 캡슐화하세요.

studyDetail.isAttendanceDayNotPassed(LocalDate.now())와 같은 중요한 로직은 StudyDetail 엔티티에 메서드로 캡슐화하는 것이 좋습니다. 이는 코드의 가독성과 유지보수성을 높입니다.

Comment on lines +97 to +105
public List<StudyMentorAttendanceResponse> getAttendanceNumbers(Long studyId) {
List<StudyDetail> studyDetails = studyDetailRepository.findAllByStudyIdOrderByWeekAsc(studyId);

// 출석일이 오늘 or 오늘이후인 StudyDetail
return studyDetails.stream()
.filter(studyDetail -> studyDetail.isAttendanceDayNotPassed(LocalDate.now()))
.map(StudyMentorAttendanceResponse::from)
.toList();
}
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

예외 처리 및 엣지 케이스를 고려하세요.

현재 메서드는 예외 처리나 엣지 케이스를 고려하지 않고 있습니다. 예를 들어, studyDetailRepository.findAllByStudyIdOrderByWeekAsc(studyId)가 빈 리스트를 반환할 경우를 처리하는 로직이 필요할 수 있습니다.

다음과 같은 코드를 추가하여 예외 처리를 강화할 수 있습니다:

@Transactional(readOnly = true)
public List<StudyMentorAttendanceResponse> getAttendanceNumbers(Long studyId) {
    List<StudyDetail> studyDetails = studyDetailRepository.findAllByStudyIdOrderByWeekAsc(studyId);
    if (studyDetails.isEmpty()) {
        throw new CustomException(STUDY_DETAILS_NOT_FOUND);
    }

    return studyDetails.stream()
            .filter(studyDetail -> studyDetail.isAttendanceDayNotPassed(LocalDate.now()))
            .map(StudyMentorAttendanceResponse::from)
            .toList();
}
Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
public List<StudyMentorAttendanceResponse> getAttendanceNumbers(Long studyId) {
List<StudyDetail> studyDetails = studyDetailRepository.findAllByStudyIdOrderByWeekAsc(studyId);
// 출석일이 오늘 or 오늘이후인 StudyDetail
return studyDetails.stream()
.filter(studyDetail -> studyDetail.isAttendanceDayNotPassed(LocalDate.now()))
.map(StudyMentorAttendanceResponse::from)
.toList();
}
@Transactional(readOnly = true)
public List<StudyMentorAttendanceResponse> getAttendanceNumbers(Long studyId) {
List<StudyDetail> studyDetails = studyDetailRepository.findAllByStudyIdOrderByWeekAsc(studyId);
if (studyDetails.isEmpty()) {
throw new CustomException(STUDY_DETAILS_NOT_FOUND);
}
return studyDetails.stream()
.filter(studyDetail -> studyDetail.isAttendanceDayNotPassed(LocalDate.now()))
.map(StudyMentorAttendanceResponse::from)
.toList();
}

Copy link

Job Summary for Gradle

Check Style and Test to Develop :: build-test
Gradle Root Project Requested Tasks Gradle Version Build Outcome Build Scan®
gdsc check 8.5 Build Scan published

@seulgi99 seulgi99 merged commit a221b83 into develop Aug 26, 2024
1 check passed
@seulgi99 seulgi99 deleted the feature/687-get-mentor-attendace-number branch August 26, 2024 06:31
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
✨ feature 새로운 기능 추가 및 수정
Projects
None yet
Development

Successfully merging this pull request may close these issues.

✨ 스터디 멘토 주차별 출결번호 조회 API 추가
3 participants