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: StudyAchievement가 BaseEntity 확장하도록 수정 #813

Merged

Conversation

Sangwook02
Copy link
Member

@Sangwook02 Sangwook02 commented Oct 29, 2024

🌱 관련 이슈

📌 작업 내용 및 특이사항

  • 지난번에 StudyAchievement 만들 때 누락한 부분이 있어서 추가했습니다~

📝 참고사항

📚 기타

Summary by CodeRabbit

  • 기능 개선
    • StudyAchievement 클래스가 BaseEntity 클래스를 상속하도록 수정되어, 공통 속성과 메서드를 활용할 수 있게 되었습니다.

@Sangwook02 Sangwook02 added the ✨ feature 새로운 기능 추가 및 수정 label Oct 29, 2024
@Sangwook02 Sangwook02 self-assigned this Oct 29, 2024
@Sangwook02 Sangwook02 requested a review from a team as a code owner October 29, 2024 07:32
Copy link

coderabbitai bot commented Oct 29, 2024

Walkthrough

StudyAchievement 클래스가 BaseEntity 클래스를 확장하도록 수정되었습니다. 이 변경으로 StudyAchievementBaseEntity의 속성과 메서드를 상속받을 수 있게 되었습니다. 이를 위해 BaseEntity의 import 문이 추가되었으며, 클래스의 메서드, 필드 또는 주석에는 다른 수정 사항이 없습니다.

Changes

파일 경로 변경 요약
src/main/java/com/gdschongik/gdsc/domain/study/domain/StudyAchievement.java StudyAchievement 클래스가 BaseEntity를 확장하도록 수정됨.

Assessment against linked issues

Objective Addressed Explanation
StudyAchievement가 BaseEntity 확장하도록 수정 (#794)

Possibly related PRs

Suggested reviewers

  • kckc0608
  • uwoobeat

🐇 변화의 기쁨을 노래해요,
StudyAchievement가 확장되어,
BaseEntity와 함께 뛰어놀며,
새로운 길을 열어가요!
함께하는 이 순간,
성과가 가득하길 바라요! 🌟


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>, 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 resolve resolve all the CodeRabbit review comments.
  • @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.

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

🧹 Outside diff range and nitpick comments (3)
src/main/java/com/gdschongik/gdsc/domain/study/domain/StudyAchievement.java (3)

Line range hint 37-43: AchievementType에 대한 문서화가 필요합니다.

achievementType 필드의 가능한 값들과 각각의 의미를 문서화하면 코드의 가독성과 유지보수성이 향상될 것 같습니다.

다음과 같이 문서화를 추가하는 것을 제안드립니다:

    @Enumerated(EnumType.STRING)
+   /**
+    * 학습 성취 유형을 나타냅니다.
+    * 예시:
+    * - COMPLETION: 학습 완료
+    * - PARTICIPATION: 참여
+    * 등의 값을 가질 수 있습니다.
+    */
    private AchievementType achievementType;

Line range hint 22-24: 성능 최적화를 위한 인덱스 추가 검토가 필요합니다.

유니크 제약 조건이 걸린 컬럼들에 대해 인덱스 추가를 고려해보시면 좋을 것 같습니다. 특히 member_id와 study_id로 조회하는 쿼리가 자주 발생할 것으로 예상됩니다.

다음과 같은 인덱스 추가를 제안드립니다:

@Table(
    uniqueConstraints = {
        @UniqueConstraint(columnNames = {"member_id", "study_id", "achievement_type"})
    },
+   indexes = {
+       @Index(name = "idx_study_achievement_member", columnList = "member_id"),
+       @Index(name = "idx_study_achievement_study", columnList = "study_id")
+   }
)

파라미터 유효성 검증이 필요합니다.

StudyAchievement 엔티티의 create 메서드에 파라미터 유효성 검증이 필요합니다. 다른 도메인 엔티티들의 패턴을 보면 대부분 필수 파라미터에 대한 null 체크를 수행하고 있습니다.

public static StudyAchievement create(Member student, Study study, AchievementType achievementType) {
+   if (student == null || study == null || achievementType == null) {
+       throw new CustomException(STUDY_ACHIEVEMENT_PARAMETER_NULL);
+   }
    return StudyAchievement.builder()
            .student(student)
            .study(study)
            .achievementType(achievementType)
            .build();
}
🔗 Analysis chain

Line range hint 45-57: 파라미터 유효성 검증이 필요합니다.

create 메서드에서 null 체크 등의 기본적인 유효성 검증을 추가하면 좋을 것 같습니다.

다음과 같은 검증 로직 추가를 제안드립니다:

    public static StudyAchievement create(Member student, Study study, AchievementType achievementType) {
+       if (student == null || study == null || achievementType == null) {
+           throw new IllegalArgumentException("필수 파라미터가 누락되었습니다.");
+       }
        return StudyAchievement.builder()
                .student(student)
                .study(study)
                .achievementType(achievementType)
                .build();
    }

아래 스크립트로 다른 엔티티들의 유효성 검증 패턴을 확인해보겠습니다:


Let's analyze the validation patterns and builder usage across the codebase to make a more informed suggestion.


Let's analyze the validation patterns in the codebase to determine if parameter validation is needed.


Let's analyze validation patterns across the domain to make a more informed decision about whether parameter validation is needed.

🏁 Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Description: 다른 엔티티들의 유효성 검증 패턴 확인
rg -t java "throw new IllegalArgumentException" "src/main/java/com/gdschongik/gdsc/domain"

Length of output: 90


Script:

#!/bin/bash
# Check for any validation patterns in entity creation methods
ast-grep --pattern 'public static $_ create($$$) {
  $$$
}'

# Also check for builder pattern usage
ast-grep --pattern '$$$
return $_.builder()
  .$$$
  .build();'

Length of output: 13017


Script:

#!/bin/bash
# Check for any null checks or validation in the codebase
rg -t java "if.*==\s*null\b.*throw" -A 2

Length of output: 42


Script:

#!/bin/bash
# Look for any custom validation exceptions
fd -e java -x grep -l "Exception" {} \; | xargs cat

Length of output: 412056


Script:

#!/bin/bash
# Check for validation patterns in create methods
ast-grep --pattern 'public static $_ create($$$) {
  if ($$$) {
    throw new $Exception($$$);
  }
  $$$
}'

# Also check for any validation in StudyAchievement class
ast-grep --pattern 'class StudyAchievement {
  $$$
  private StudyAchievement($$$) {
    $$$
  }
  $$$
}'

Length of output: 217


Script:

#!/bin/bash
# Check for any null checks in similar create methods
rg "if.*null.*throw" -A 2 "src/main/java/com/gdschongik/gdsc/domain"

Length of output: 68


Script:

#!/bin/bash
# Check for validation in similar entity creation methods
rg "private.*constructor.*\{" -A 5 "src/main/java/com/gdschongik/gdsc/domain/study/domain/StudyAchievement.java"

# Check for any validation in create methods
rg "public static.*create.*\{" -A 5 "src/main/java/com/gdschongik/gdsc/domain/study/domain/StudyAchievement.java"

# Look for any validation methods
rg "validate.*\{" -A 5 "src/main/java/com/gdschongik/gdsc/domain/study/domain/StudyAchievement.java"

Length of output: 615


Script:

#!/bin/bash
# Check for similar entity creation patterns in the domain
rg "private.*constructor.*\{|public static.*create.*\{" -A 5 "src/main/java/com/gdschongik/gdsc/domain"

# Look for null validation patterns in other domain entities
rg "if.*==\s*null.*throw" -A 2 "src/main/java/com/gdschongik/gdsc/domain"

# Check for any validator classes
fd -e java -x grep -l "Validator" {} \; | xargs cat

Length of output: 184809

📜 Review details

Configuration used: CodeRabbit UI
Review profile: CHILL

📥 Commits

Files that changed from the base of the PR and between 014cf8c and 1b9045c.

📒 Files selected for processing (1)
  • src/main/java/com/gdschongik/gdsc/domain/study/domain/StudyAchievement.java (2 hunks)
🔇 Additional comments (1)
src/main/java/com/gdschongik/gdsc/domain/study/domain/StudyAchievement.java (1)

3-3: BaseEntity 상속 구현이 적절합니다.

BaseEntity를 상속받음으로써 공통 필드(생성일시, 수정일시 등)를 활용할 수 있게 되었습니다.

Also applies to: 26-26

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
상용DB에도 해당사항 반영해주세요

Copy link
Member

@kckc0608 kckc0608 left a comment

Choose a reason for hiding this comment

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

👍

@Sangwook02 Sangwook02 merged commit b4e158b into develop Nov 1, 2024
1 check passed
@Sangwook02 Sangwook02 deleted the feature/794-study-achievement-extends-base-entity branch November 1, 2024 04:58
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.

✨ StudyAchievement가 BaseEntity 확장하도록 수정
3 participants