-
Notifications
You must be signed in to change notification settings - Fork 2
Refactor: card create refactor #192
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
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.
Summary of Changes
Hello @hamtorygoals, I'm Gemini Code Assist1! I'm currently reviewing this pull request and will post my feedback shortly. In the meantime, here's a summary to help you and other reviewers quickly get up to speed!
이 PR은 카드 생성 시 삭제된 카드로 인해 동일한 식사 유형의 카드를 다시 생성할 수 없었던 문제를 해결합니다. 사용자가 카드를 삭제한 후에도 동일한 식사 유형으로 새로운 카드를 생성할 수 있도록 기존 카드 중복 확인 로직이 개선되었습니다.
Highlights
- 카드 중복 확인 로직 개선: CardRepository에 isDeletedFalse 조건을 포함하는 새로운 existsByUserIdAndMealAndCreatedAtBetweenAndIsDeletedFalse 메서드를 추가하여, 삭제된 카드는 중복 확인 대상에서 제외되도록 했습니다.
- 카드 생성 서비스 로직 업데이트: CardServiceImpl에서 카드 생성 시 중복 확인을 위해 기존 existsByUserIdAndMealAndCreatedAtBetween 대신 새로 추가된 existsByUserIdAndMealAndCreatedAtBetweenAndIsDeletedFalse 메서드를 사용하도록 변경했습니다.
Using Gemini Code Assist
The full guide for Gemini Code Assist can be found on our documentation page, here are some quick tips.
Invoking Gemini
You can request assistance from Gemini at any point in your pull request via creating an issue comment (i.e. comment on the pull request page) using either /gemini <command> or @gemini-code-assist <command>. Below is a summary of the supported commands.
| Feature | Command | Description |
|---|---|---|
| Code Review | /gemini review |
Performs a code review for the current pull request in its current state. |
| Pull Request Summary | /gemini summary |
Provides a summary of the current pull request in its current state. |
| Comment | @gemini-code-assist | Responds in comments when explicitly tagged, both in issue comments and review comments. |
| Help | /gemini help |
Displays a list of available commands. |
Customization
To customize Gemini Code Assist for GitHub experience, repository maintainers can create a configuration file and/or provide a custom code review style guide (such as PEP-8 for Python) by creating and adding files to a .gemini/ folder in the base of the repository. Detailed instructions can be found here.
Limitations & Feedback
Gemini Code Assist may make mistakes. Please leave feedback on any instances where its feedback is incorrect or counter productive. You can react with 👍 and 👎 on @gemini-code-assist comments. If you're interested in giving your feedback about your experience with Gemini Code Assist for Github and other Google products, sign up here.
You can also get AI-powered code generation, chat, as well as code reviews directly in the IDE at no cost with the Gemini Code Assist IDE Extension.
Footnotes
-
Review the Privacy Notices, Generative AI Prohibited Use Policy, Terms of Service, and learn how to configure Gemini Code Assist in GitHub here. Gemini can make mistakes, so double check it and use code with caution. ↩
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.
Code Review
안녕하세요. 카드 생성 로직 리팩토링 PR 리뷰입니다.
카드 생성 시 중복을 확인할 때 삭제된 카드를 제외하도록 수정하신 점이 좋습니다. 이를 통해 설명해주신 버그가 잘 해결될 것으로 보입니다.
코드 가독성 및 유지보수성 향상을 위해 CardRepository에 추가된 메서드에 대해 @Query 어노테이션을 사용하여 더 간결한 이름으로 변경하는 것을 제안했습니다. 이 리포지토리의 다른 부분에서도 @Query를 사용하고 있어 일관성 측면에서도 좋은 변경이 될 것입니다. 관련하여 CardServiceImpl의 메서드 호출 부분도 수정이 필요하여 함께 코멘트 남겼습니다.
전반적으로 좋은 수정이라고 생각합니다. 수고하셨습니다!
| boolean existsByUserIdAndMealAndCreatedAtBetweenAndIsDeletedFalse( | ||
| Long userId, | ||
| Meal meal, | ||
| LocalDateTime startOfDay, | ||
| LocalDateTime endOfDay | ||
| ); |
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.
메서드 이름이 너무 길어 가독성이 저하될 수 있습니다. Spring Data JPA의 쿼리 메서드 이름 규칙은 편리하지만, 조건이 많아지면 메서드 이름이 과도하게 길어지는 단점이 있습니다.
@Query 어노테이션을 사용하여 JPQL을 직접 작성하면, 메서드 이름을 더 간결하고 의미있게 만들 수 있어 코드의 가독성과 유지보수성을 높일 수 있습니다. 이 리포지토리의 다른 부분(findFeedExcludeBlocked, findCardsByHashtag 등)에서도 @Query를 사용하고 있으므로, 일관성을 유지하는 좋은 방법이기도 합니다.
아래와 같이 변경하는 것을 제안합니다.
| boolean existsByUserIdAndMealAndCreatedAtBetweenAndIsDeletedFalse( | |
| Long userId, | |
| Meal meal, | |
| LocalDateTime startOfDay, | |
| LocalDateTime endOfDay | |
| ); | |
| @Query("select count(c) > 0 from Card c where c.user.id = :userId and c.meal = :meal and c.createdAt between :startOfDay and :endOfDay and c.isDeleted = false") | |
| boolean existsActiveCardByMealAndDate( | |
| @Param("userId") Long userId, | |
| @Param("meal") Meal meal, | |
| @Param("startOfDay") LocalDateTime startOfDay, | |
| @Param("endOfDay") LocalDateTime endOfDay | |
| ); |
|
|
||
| // 같은 날짜, 같은 meal 타입 카드 중복 확인 | ||
| boolean existsSameMealCard = cardRepository.existsByUserIdAndMealAndCreatedAtBetween( | ||
| boolean existsSameMealCard = cardRepository.existsByUserIdAndMealAndCreatedAtBetweenAndIsDeletedFalse( |
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.
#️⃣연관된 이슈
📝작업 내용
스크린샷 (선택)
💬리뷰 요구사항(선택)