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: 나의 수강중인 스터디 조회 API 추가 #656

Merged
merged 4 commits into from
Aug 21, 2024

Conversation

Sangwook02
Copy link
Member

@Sangwook02 Sangwook02 commented Aug 20, 2024

🌱 관련 이슈

📌 작업 내용 및 특이사항

  • 와우클래스의 나의 스터디 페이지 진입시, 내가 어떤 스터디를 듣고 있는지 조회할 수 있어야 합니다.
  • 따라서, 현재 듣고 있는 스터디의 id를 조회하는 api를 구현했습니다.

📝 참고사항

📚 기타

Summary by CodeRabbit

  • 신규 기능

    • 사용자가 등록된 진행 중인 연구 정보를 조회할 수 있는 새로운 API 엔드포인트 추가.
    • 현재 연구를 가져오는 기능을 제공하는 메소드 추가.
  • 개선 사항

    • 연구 이력 데이터를 기반으로 하는 응답 구조를 정의하는 새로운 응답 형식 추가.

@Sangwook02 Sangwook02 self-assigned this Aug 20, 2024
@Sangwook02 Sangwook02 requested a review from a team as a code owner August 20, 2024 13:04
Copy link

coderabbitai bot commented Aug 20, 2024

Caution

Review failed

The pull request is closed.

## Walkthrough

이번 변경 사항은 `StudentStudyController``StudentStudyService`에 새로운 메소드를 추가하여 사용자가 현재 참여 중인 스터디 정보를 조회할 수 있는 기능을 강화합니다. 새로운 API 엔드포인트는 사용자 경험을 개선하고, 스터디 데이터 접근성을 높이는 역할을 합니다.

## Changes

| 파일 경로                                         | 변경 요약                                               |
|--------------------------------------------------|-------------------------------------------------------|
| `src/main/java/com/gdschongik/gdsc/domain/study/api/StudentStudyController.java`, `src/main/java/com/gdschongik/gdsc/domain/study/application/StudentStudyService.java` | `getMyOngoingStudy()``getMyCurrentStudy()` 메소드 추가하여 현재 참여 중인 스터디 조회 기능 구현. |
| `src/main/java/com/gdschongik/gdsc/domain/study/dto/response/StudentOngoingStudyResponse.java`, `src/main/java/com/gdschongik/gdsc/domain/study/dto/response/StudentMyCurrentStudyResponse.java` | 새로운 레코드 `StudentMyCurrentStudyResponse` 추가 및 `StudentOngoingStudyResponse` 수정하여 스터디 정보를 응답 형식으로 변환하는 기능 제공. |

## Sequence Diagram(s)

```mermaid
sequenceDiagram
    participant User
    participant Controller
    participant Service
    participant Repository

    User->>Controller: getMyOngoingStudy()
    Controller->>Service: getMyOngoingStudy()
    Service->>Repository: fetchStudyHistories()
    Repository-->>Service: studyHistories
    Service-->>Controller: StudentOngoingStudyResponse
    Controller-->>User: Ongoing Study Data

    User->>Controller: getMyCurrentStudy()
    Controller->>Service: getMyCurrentStudy()
    Service->>Repository: fetchStudyHistories()
    Repository-->>Service: studyHistories
    Service-->>Controller: StudentMyCurrentStudyResponse
    Controller-->>User: Current Study Data

Assessment against linked issues

Objective Addressed Explanation
수강중인 스터디 조회 API 추가 (#655)

🐰 변화를 축하해요, 모두들!

스터디를 찾아 헤매는 즐거운 여정,
새로운 길을 열어준 코드의 환영.
함께 배우고, 성장하는 이 순간,
Rabbit과 함께 뛰어보아요, 정원에서! 🌷✨


<!-- walkthrough_end --><!-- commit_ids_reviewed_start -->

<!-- f217b3bd3cae3cdf4f66a27ce0a1d39ca0492f10 -->

<!-- commit_ids_reviewed_end --><!-- This is an auto-generated comment: raw summary by coderabbit.ai -->

<!--

src/main/java/com/gdschongik/gdsc/domain/study/api/StudentStudyController.java: ## AI-generated summary of changes

The diff introduces new endpoints in the StudentStudyController class, enhancing the functionality of the API. A new method getMyOngoingStudy() is added, allowing users to retrieve information about ongoing studies they are enrolled in. This method is annotated with @Operation, providing a summary and description for API documentation purposes. It returns a ResponseEntity<StudentOngoingStudyResponse>, which encapsulates the response data structure for the ongoing studies. Additionally, a new method getMyCurrentStudy() is introduced, which allows users to retrieve information about the studies they are currently enrolled in, also annotated with @Operation and returning a ResponseEntity<StudentMyCurrentStudyResponse>.

Alterations to the declarations of exported or public entities

  • public ResponseEntity<StudentOngoingStudyResponse> getMyOngoingStudy() in class StudentStudyController in src/main/java/com/gdschongik/gdsc/domain/study/api/StudentStudyController.java → new method added.
  • public ResponseEntity<StudentMyCurrentStudyResponse> getMyCurrentStudy() in class StudentStudyController in src/main/java/com/gdschongik/gdsc/domain/study/api/StudentStudyController.java → new method added.

src/main/java/com/gdschongik/gdsc/domain/study/application/StudentStudyService.java: ## AI-generated summary of changes

The changes in StudentStudyService.java introduce two new public methods: getMyOngoingStudy and getMyCurrentStudy. The getMyOngoingStudy method retrieves the ongoing study for the current member, annotated with @Transactional(readOnly = true), indicating it is intended for read operations. It fetches the current member's study histories and filters to find the first ongoing study, returning a StudentOngoingStudyResponse. The getMyCurrentStudy method similarly retrieves the current study for the member, following the same logic and returning a StudentMyCurrentStudyResponse. These additions enhance the service's capabilities and improve user experience by providing easy access to study data.

Alterations to the declarations of exported or public entities

  • public void attend(Long studyDetailId, StudyAttendCreateRequest request) in class StudentStudyService in src/main/java/com/gdschongik/gdsc/domain/study/application/StudentStudyService.javapublic StudentOngoingStudyResponse getMyOngoingStudy() in class StudentStudyService in src/main/java/com/gdschongik/gdsc/domain/study/application/StudentStudyService.java
  • public StudentMyCurrentStudyResponse getMyCurrentStudy() in class StudentStudyService in src/main/java/com/gdschongik/gdsc/domain/study/application/StudentStudyService.java → new method added.

src/main/java/com/gdschongik/gdsc/domain/study/dto/response/StudentOngoingStudyResponse.java: ## AI-generated summary of changes

The file StudentOngoingStudyResponse.java defines a record in Java that encapsulates a response structure for ongoing student studies. It includes a single field, studyId, which is of type Long. The primary functionality of this record is to provide a static method, from, which facilitates the creation of a StudentOngoingStudyResponse instance from a StudyHistory object. This method ensures that the response can gracefully handle cases where the input data may be incomplete or absent.

Alterations to the declarations of exported or public entities

  • public record StudentOngoingStudyResponse(Long studyId) in src/main/java/com/gdschongik/gdsc/domain/study/dto/response/StudentOngoingStudyResponse.javapublic static StudentOngoingStudyResponse from(StudyHistory studyHistory) in src/main/java/com/gdschongik/gdsc/domain/study/dto/response/StudentOngoingStudyResponse.java

src/main/java/com/gdschongik/gdsc/domain/study/dto/response/StudentMyCurrentStudyResponse.java: ## AI-generated summary of changes

The newly introduced file StudentMyCurrentStudyResponse.java defines a record class that encapsulates the response structure for a student's current study details. The primary purpose of this class is to provide a clean and efficient way to represent the study ID associated with a student's ongoing study. The record contains a single field, studyId, which is of type Long. A static method, from, is provided to facilitate the creation of an instance of StudentMyCurrentStudyResponse from a StudyHistory object, ensuring that the response object is always instantiated correctly based on the provided StudyHistory.

Alterations to the declarations of exported or public entities

  • public record StudentMyCurrentStudyResponse(Long studyId) in src/main/java/com/gdschongik/gdsc/domain/study/dto/response/StudentMyCurrentStudyResponse.javapublic static StudentMyCurrentStudyResponse from(StudyHistory studyHistory) in src/main/java/com/gdschongik/gdsc/domain/study/dto/response/StudentMyCurrentStudyResponse.java

-->

<!-- end of auto-generated comment: raw summary by coderabbit.ai --><!-- This is an auto-generated comment: pr objectives by coderabbit.ai -->

<!--

## PR Summary

The pull request titled "feat: 나의 수강중인 스터디 조회 API 추가" introduces a new API that allows users to retrieve the studies they are currently enrolled in. This feature is intended to enhance the "My Studies" page of the WowClass application, enabling users to easily access the IDs of their active studies. The implementation addresses a key user need for quick access to their current study information. This PR is linked to issue #655, which it aims to close upon successful integration.

## Objectives from Linked Issues

The linked issue #655 focuses on adding an API that enables users to retrieve information about the studies they are currently enrolled in. The primary objective is to enhance the user experience on the "My Studies" page by allowing users to view their active studies. This functionality is crucial for improving user engagement and ensuring that users can effectively manage their study activities within the application. The successful completion of this API is expected to meet the requirements outlined in the issue, contributing to the overall enhancement of the WowClass platform.

-->

<!-- end of auto-generated comment: pr objectives by coderabbit.ai --><!-- tips_start -->

---



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?

<details>
<summary>Share</summary>

- [X](https://twitter.com/intent/tweet?text=I%20just%20used%20%40coderabbitai%20for%20my%20code%20review%2C%20and%20it%27s%20fantastic%21%20It%27s%20free%20for%20OSS%20and%20offers%20a%20free%20trial%20for%20the%20proprietary%20code.%20Check%20it%20out%3A&url=https%3A//coderabbit.ai)
- [Mastodon](https://mastodon.social/share?text=I%20just%20used%20%40coderabbitai%20for%20my%20code%20review%2C%20and%20it%27s%20fantastic%21%20It%27s%20free%20for%20OSS%20and%20offers%20a%20free%20trial%20for%20the%20proprietary%20code.%20Check%20it%20out%3A%20https%3A%2F%2Fcoderabbit.ai)
- [Reddit](https://www.reddit.com/submit?title=Great%20tool%20for%20code%20review%20-%20CodeRabbit&text=I%20just%20used%20CodeRabbit%20for%20my%20code%20review%2C%20and%20it%27s%20fantastic%21%20It%27s%20free%20for%20OSS%20and%20offers%20a%20free%20trial%20for%20proprietary%20code.%20Check%20it%20out%3A%20https%3A//coderabbit.ai)
- [LinkedIn](https://www.linkedin.com/sharing/share-offsite/?url=https%3A%2F%2Fcoderabbit.ai&mini=true&title=Great%20tool%20for%20code%20review%20-%20CodeRabbit&summary=I%20just%20used%20CodeRabbit%20for%20my%20code%20review%2C%20and%20it%27s%20fantastic%21%20It%27s%20free%20for%20OSS%20and%20offers%20a%20free%20trial%20for%20proprietary%20code)

</details>

<details>
<summary>Tips</summary>

### Chat

There are 3 ways to chat with [CodeRabbit](https://coderabbit.ai):

- 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](https://docs.coderabbit.ai/guides/configure-coderabbit) 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](https://coderabbit.ai/docs) for detailed information on how to use CodeRabbit.
- Join our [Discord Community](https://discord.com/invite/GsXnASn26c) to get help, request features, and share feedback.
- Follow us on [X/Twitter](https://twitter.com/coderabbitai) for updates and announcements.

</details>

<!-- tips_end -->

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

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 072933e and f217b3b.

Files selected for processing (3)
  • src/main/java/com/gdschongik/gdsc/domain/study/api/StudentStudyController.java (2 hunks)
  • src/main/java/com/gdschongik/gdsc/domain/study/application/StudentStudyService.java (2 hunks)
  • src/main/java/com/gdschongik/gdsc/domain/study/dto/response/StudentOngoingStudyResponse.java (1 hunks)
Additional comments not posted (3)
src/main/java/com/gdschongik/gdsc/domain/study/dto/response/StudentOngoingStudyResponse.java (1)

5-11: 잘 구현된 StudentOngoingStudyResponse 클래스입니다.

이 클래스는 StudyHistory 객체를 StudentOngoingStudyResponse로 변환하는 from 메서드를 포함하고 있으며, null 값을 적절히 처리하고 있습니다. 레코드 기능을 활용하여 불변성을 유지하는 점이 좋습니다.

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

58-63: 새로운 API 엔드포인트 getMyOngoingStudy가 잘 추가되었습니다.

이 메서드는 현재 수강 중인 스터디를 조회하는 기능을 제공하며, 적절한 API 문서화를 위한 어노테이션이 포함되어 있습니다. ResponseEntity를 사용하여 응답을 처리하는 방식이 적절합니다.

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

96-103: getMyOngoingStudy 메서드가 잘 구현되었습니다.

이 메서드는 현재 멤버의 진행 중인 스터디를 조회하며, @Transactional(readOnly = true) 어노테이션을 통해 읽기 전용 작업임을 명시하고 있습니다. memberUtil을 사용하여 현재 멤버를 가져오고, 스트림을 사용하여 필터링하는 방식이 효율적입니다.

Copy link
Member

@uwoobeat uwoobeat left a comment

Choose a reason for hiding this comment

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

lgtm

@@ -90,4 +92,13 @@ public void attend(Long studyDetailId, StudyAttendCreateRequest request) {

log.info("[StudyService] 스터디 출석: attendanceId={}", attendance.getId());
}

@Transactional(readOnly = true)
public StudentOngoingStudyResponse getMyOngoingStudy() {
Copy link
Member

Choose a reason for hiding this comment

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

ongoing은 현재 진행중인 이라는 뜻이 있어서, 내가 '수강중인' 스터디라는 맥락을 드러내기엔 부적합한 것 같습니다.
그냥 getMyCurrentStudygetMyEnrolledStudy 가 적절할듯 하네요

@Transactional(readOnly = true)
public StudentOngoingStudyResponse getMyOngoingStudy() {
Member currentMember = memberUtil.getCurrentMember();
Optional<StudyHistory> studyHistory = studyHistoryRepository.findAllByMentee(currentMember).stream()
Copy link
Member

Choose a reason for hiding this comment

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

마이너하긴 한데 여기서 orElse(null)까지 끌고가는게 의미적으로 더 낫지 않을까 싶네요
파라미터에서 로직을 수행하는 건 한 라인에 두 가지 일을 수행하는 거라 별로라서요

Copy link
Member Author

Choose a reason for hiding this comment

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

그렇네요
굳이 파라미터에서 할 필요없겠어요

수정 후 반영했습니다~

Copy link
Contributor

@seulgi99 seulgi99 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

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

@Sangwook02 Sangwook02 merged commit 554d567 into develop Aug 21, 2024
1 check passed
@Sangwook02 Sangwook02 deleted the feature/655-get-ongoing-study branch August 21, 2024 06:06
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

✨ 수강중인 스터디 조회 API 추가
3 participants