Skip to content

Conversation

@AlphaBs
Copy link
Member

@AlphaBs AlphaBs commented Jan 6, 2026

History

🚀 Major Changes & Explanations

📷 Test Image

💡 ETC

@gemini-code-assist
Copy link
Contributor

Summary of Changes

Hello @AlphaBs, 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은 Gemini AI를 활용한 도서 추천 시스템을 도입합니다. 사용자 온보딩 데이터를 기반으로 개인화된 도서 추천을 생성하고, 이를 API를 통해 제공하며, 추천된 도서 목록을 저장하고 조회할 수 있는 기능을 추가합니다. 기존 크롤링 로직에서 책 검색 및 저장 부분을 AladinService로 옮겨 책임 분리를 명확히 했습니다.

Highlights

  • 책 검색 및 저장 로직 중앙화: 네이버 블로그 크롤링 전략에서 책 검색 및 저장 로직을 AladinService로 이관하여 중복을 제거하고 책임 분리를 명확히 했습니다.
  • 도서 추천 API 도입: 새로운 도서 추천 API (/api/v1/recommendation)를 추가하여 사용자별 도서 추천 기능을 제공합니다.
  • 회원별 추천 엔티티 및 레포지토리 추가: 회원별 도서 추천 정보를 저장하기 위한 MemberBookRecommendation 엔티티 및 관련 레포지토리를 추가했습니다.
  • Gemini AI 기반 추천 시스템 통합: Gemini AI를 활용하여 사용자 온보딩 데이터를 기반으로 도서를 추천하는 GeminiBookRecommendationProvider 서비스를 구현했습니다.
  • 핵심 추천 로직 구현: RecommendationService를 통해 온보딩 정보, Gemini 추천, 알라딘 검색을 통합하여 도서 추천을 생성하고 관리하는 핵심 로직을 구현했습니다.

🧠 New Feature in Public Preview: You can now enable Memory to help Gemini Code Assist learn from your team's feedback. This makes future code reviews more consistent and personalized to your project's style. Click here to enable Memory in your admin console.

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 by creating a comment using either /gemini <command> or @gemini-code-assist <command>. Below is a summary of the supported commands on the current page.

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 pull request 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.

@github-actions
Copy link

github-actions bot commented Jan 6, 2026

Test Results

103 files  103 suites   22s ⏱️
516 tests 516 ✅ 0 💤 0 ❌
526 runs  526 ✅ 0 💤 0 ❌

Results for commit bcb5109.

♻️ This comment has been updated with latest results.

Copy link
Contributor

@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은 Gemini를 사용하여 도서 추천 기능을 추가하는 것을 목표로 합니다. 전반적인 코드 구조는 컨트롤러, 서비스, 리포지토리로 잘 분리되어 있으며 명확합니다. 도서 검색 로직을 AladinService로 리팩토링한 점도 좋은 개선입니다. 코드 품질을 더욱 향상시키기 위해 엔티티 설계, 성능, API 사용 패턴과 관련하여 몇 가지 제안 사항을 남깁니다.

return geminiSdkClient.generateContent(request);
}

private GeminiRequest<BookRecommendationResponses> createRequest(OnboardingResultResponse onboarding) {
Copy link
Contributor

Choose a reason for hiding this comment

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

image

세인님 코드보니까 GeminiQuizPromptProvider랑 GeminiRequestFactory 합쳐도 되겠다라는 생각이 드네요 감사합니다!

# Conflicts:
#	src/main/java/book/book/crawler/strategy/NaverBlogPostCrawlingStrategy.java
@AlphaBs
Copy link
Member Author

AlphaBs commented Jan 12, 2026

/gemini review

Copy link
Contributor

@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

Gemini를 이용한 도서 추천 기능 추가 PR 잘 보았습니다. 새로운 기능을 추가하면서 책임에 따라 서비스와 컨트롤러를 분리하고, 기존의 책 검색 및 저장 로직을 AladinService로 중앙화하는 리팩토링을 진행한 점이 인상적입니다. 코드 구조가 전반적으로 잘 잡혀있으나, API 응답 설계, 동시성 처리, 프롬프트 생성 및 예외 처리 등 몇 가지 개선할 수 있는 부분들이 보여 의견을 남깁니다.

private final GeminiBookRecommendationProvider geminiBookRecommendationProvider;
private final AladinService aladinService;

@DistributedLock(key = "'recommendation_lock:' + #member.id", waitTime = 0)
Copy link
Contributor

Choose a reason for hiding this comment

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

high

Gemini API 호출을 포함하는 generateBookRecommendationForMember 메서드 전체에 @DistributedLock이 적용되어 있습니다. API 호출은 시간이 오래 걸릴 수 있는데, 기본 leaseTime인 10초를 초과할 경우 락이 조기 해제될 위험이 있습니다. 이 경우 다른 스레드가 진입하여 추천 컬렉션을 중복으로 저장하는 등의 경쟁 상태(race condition)가 발생할 수 있습니다. leaseTime을 API 타임아웃보다 충분히 긴 시간으로 명시적으로 설정하는 것을 권장합니다.

Suggested change
@DistributedLock(key = "'recommendation_lock:' + #member.id", waitTime = 0)
@DistributedLock(key = "'recommendation_lock:' + #member.id", waitTime = 0, leaseTime = 30)

private final MemberRepository memberRepository;

@GetMapping("/members/{memberId}/books/refresh")
public List<Book> refreshBooksForMember(@PathVariable Long memberId) {
Copy link
Contributor

Choose a reason for hiding this comment

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

medium

컨트롤러 메서드가 JPA 엔티티(List<Book>)를 직접 반환하고 있습니다. 이는 API 응답이 데이터베이스 스키마에 강하게 결합되게 만들고, 의도치 않은 정보 노출이나 직렬화 문제를 일으킬 수 있습니다. 응답을 위한 DTO(Data Transfer Object)를 정의하여 사용하는 것을 권장합니다. 이 문제는 getBooksForMember 메서드에도 동일하게 적용됩니다.

}

@GetMapping("/members/{memberId}/books")
public List<Book> getBooksForMember(@PathVariable Long memberId) {
Copy link
Contributor

Choose a reason for hiding this comment

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

medium

컨트롤러 메서드가 JPA 엔티티(List<Book>)를 직접 반환하고 있습니다. 이는 API 응답이 데이터베이스 스키마에 강하게 결합되게 만들고, 의도치 않은 정보 노출이나 직렬화 문제를 일으킬 수 있습니다. 응답을 위한 DTO(Data Transfer Object)를 정의하여 사용하는 것을 권장합니다.

Comment on lines 46 to 47
onboarding.favoriteAuthor(),
onboarding.favoriteBook());
Copy link
Contributor

Choose a reason for hiding this comment

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

medium

Gemini 프롬프트 생성 시 onboarding.favoriteAuthor()onboarding.favoriteBook()이 null이거나 비어있을 경우, 문자열 "null"이 프롬프트에 포함됩니다. 이는 모델에게 혼란을 줄 수 있습니다. keywords처럼 isBlank() 체크와 함께 "없음"과 같은 명확한 플레이스홀더를 사용하는 것이 좋습니다.

Suggested change
onboarding.favoriteAuthor(),
onboarding.favoriteBook());
(onboarding.favoriteAuthor() == null || onboarding.favoriteAuthor().isBlank()) ? "없음" : onboarding.favoriteAuthor(),
(onboarding.favoriteBook() == null || onboarding.favoriteBook().isBlank()) ? "없음" : onboarding.favoriteBook());

Book book = bookService.saveBooksParallel(searchResponse.getItem()).get(0);
return Optional.of(book);
} catch (Exception e) {
log.error("책 검색 중 오류 발생: {}, {}", e, bookTitle);
Copy link
Contributor

Choose a reason for hiding this comment

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

medium

로깅 포맷이 잘못 사용되었습니다. log.error("..., {}, {}", e, bookTitle) 형식은 스택 트레이스를 출력하지 않고 예외 객체의 toString() 값만 로깅하게 됩니다. 정확한 오류 분석을 위해 스택 트레이스가 로깅되도록 예외 객체는 항상 마지막 인자로 전달해야 합니다. 또한, 메시지에 사용된 인수의 순서도 실제 의도와 다른 것 같습니다.

Suggested change
log.error("책 검색 중 오류 발생: {}, {}", e, bookTitle);
log.error("책 검색 중 오류 발생: {}", bookTitle, e);

@github-actions
Copy link

🌻 테스트 커버리지 리포트

Overall Project 52.41% -1.49% 🍏
Files changed 7.41%

File Coverage
RecommendationController.java 21.95% -78.05%
RecommendationService.java 13.51% -86.49%
NaverBlogPostCrawlingStrategy.java 8.54% -1.52%
GeminiBookRecommendationProvider.java 4.2% -95.8%
MemberBookRecommendation.java 3.7% -96.3%
AladinService.java 1.08% -12.67%
BookRecommendationResponses.java 0%

@AlphaBs AlphaBs merged commit b50530a into dev Jan 18, 2026
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.

3 participants