Skip to content

Conversation

@hamtorygoals
Copy link
Member

#️⃣연관된 이슈

ex) #191

📝작업 내용

이번 PR에서 작업한 내용을 간략히 설명해주세요(이미지 첨부 가능)
카드 생성 후 삭제하고 다시 생성할 때 meal겹쳐서 생성 안되는 문제 해결

스크린샷 (선택)

💬리뷰 요구사항(선택)

리뷰어가 특별히 봐주었으면 하는 부분이 있다면 작성해주세요

ex) 메서드 XXX의 이름을 더 잘 짓고 싶은데 혹시 좋은 명칭이 있을까요?

@hamtorygoals hamtorygoals linked an issue Aug 21, 2025 that may be closed by this pull request
3 tasks
@hamtorygoals hamtorygoals self-assigned this Aug 21, 2025
@hamtorygoals hamtorygoals requested review from 2anizirong and kjhh2605 and removed request for 2anizirong August 21, 2025 05:49
Copy link

@gemini-code-assist gemini-code-assist bot left a 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

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

Copy link

@gemini-code-assist gemini-code-assist bot left a 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의 메서드 호출 부분도 수정이 필요하여 함께 코멘트 남겼습니다.

전반적으로 좋은 수정이라고 생각합니다. 수고하셨습니다!

Comment on lines +127 to +132
boolean existsByUserIdAndMealAndCreatedAtBetweenAndIsDeletedFalse(
Long userId,
Meal meal,
LocalDateTime startOfDay,
LocalDateTime endOfDay
);

Choose a reason for hiding this comment

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

medium

메서드 이름이 너무 길어 가독성이 저하될 수 있습니다. Spring Data JPA의 쿼리 메서드 이름 규칙은 편리하지만, 조건이 많아지면 메서드 이름이 과도하게 길어지는 단점이 있습니다.

@Query 어노테이션을 사용하여 JPQL을 직접 작성하면, 메서드 이름을 더 간결하고 의미있게 만들 수 있어 코드의 가독성과 유지보수성을 높일 수 있습니다. 이 리포지토리의 다른 부분(findFeedExcludeBlocked, findCardsByHashtag 등)에서도 @Query를 사용하고 있으므로, 일관성을 유지하는 좋은 방법이기도 합니다.

아래와 같이 변경하는 것을 제안합니다.

Suggested change
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(

Choose a reason for hiding this comment

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

medium

CardRepository에 제안된 변경 사항에 맞춰, 여기서도 새로운 메서드 이름을 사용하도록 수정해야 합니다. 이렇게 하면 코드의 일관성을 유지하고 가독성을 높일 수 있습니다.

Suggested change
boolean existsSameMealCard = cardRepository.existsByUserIdAndMealAndCreatedAtBetweenAndIsDeletedFalse(
boolean existsSameMealCard = cardRepository.existsActiveCardByMealAndDate(

@kjhh2605 kjhh2605 merged commit 05b3b99 into main Aug 21, 2025
2 checks passed
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.

[Refactor] card create refactor

3 participants