feat: 리뷰 번역기능 추가#417
Conversation
Summary of ChangesHello, 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은 리뷰 내용을 영어로 번역할 수 있는 기능을 추가합니다. DeepL API를 활용하며, 성능 향상을 위해 번역 결과를 DB에 캐싱하고 리뷰 수정 시 캐시를 무효화하는 로직을 포함합니다. 또한, 안정적인 API 호출을 위해 전용 RestTemplate 설정과 세분화된 예외 처리를 도입했습니다. Highlights
New Features🧠 You can now enable Memory (public preview) 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. Ignored Files
Using Gemini Code AssistThe 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
Customization To customize the 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 Limitations & Feedback Gemini Code Assist may make mistakes. Please leave feedback on any instances where its feedback is incorrect or counterproductive. 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. 리뷰를 번역해 영어로 담아, DeepL API로 뜻을 전하네. 캐시를 쌓아 속도를 높이고, 수정된 글엔 다시금 새롭게. Footnotes
|
There was a problem hiding this comment.
Code Review
이번 풀 리퀘스트는 DeepL API를 활용한 리뷰 번역 기능을 추가합니다. 이를 위해 번역 결과를 캐싱하는 review_translation 테이블 및 엔티티, DeepL 연동 클라이언트, 번역 서비스, 그리고 ReviewControllerV2에 번역 API 엔드포인트를 새롭게 도입하였으며, 리뷰 수정 시 기존 캐시를 삭제하는 로직을 추가했습니다. 코드 리뷰에서는 번역 내용 절삭 방지를 위한 DB 컬럼 타입 변경(TEXT 권장), 커넥션 풀 고갈 방지를 위한 외부 API 호출의 트랜잭션 외부 분리, 예외 처리를 위한 saveAndFlush() 사용, CI/CD 환경을 고려한 @value 기본값 설정, Spring 6 버전에 맞춘 Duration 기반 타임아웃 설정, 그리고 컨트롤러 내 미사용 매개변수 제거 등 시스템 안정성과 코드 품질을 높이기 위한 다양한 개선 사항들이 제안되었습니다.
Important
The consumer version of Gemini Code Assist on GitHub is being sunset. Starting June 18, 2026, new organization installations will be blocked, and all code review activity will officially cease on July 17, 2026.
For more details on the timeline and next steps, please review the Help Documentation.
| id BIGINT AUTO_INCREMENT PRIMARY KEY, | ||
| review_id BIGINT NOT NULL, | ||
| language VARCHAR(10) NOT NULL, | ||
| translated_content VARCHAR(600) NOT NULL, |
| @Slf4j | ||
| @RequiredArgsConstructor | ||
| @Service | ||
| @Transactional |
| factory.setConnectTimeout(2000); | ||
| factory.setReadTimeout(3000); |
There was a problem hiding this comment.
[작성자: 리뷰어, 날짜: 2025-05-15] Spring 6 / Spring Boot 3 환경에서는 정수형 timeout 설정 메서드가 deprecated 되었으므로 Duration을 사용하는 것을 권장합니다.
| factory.setConnectTimeout(2000); | |
| factory.setReadTimeout(3000); | |
| factory.setConnectTimeout(java.time.Duration.ofMillis(2000)); | |
| factory.setReadTimeout(java.time.Duration.ofMillis(3000)); |
| @PostMapping("/{reviewId}/translate") | ||
| public BaseResponse<ReviewTranslationResponse> translateReview( | ||
| @Parameter(description = "reviewId") @PathVariable("reviewId") Long reviewId, | ||
| @Parameter(description = "번역 대상 언어(현재 EN만 지원)") @RequestParam Language language, | ||
| @AuthenticationPrincipal CustomUserDetails customUserDetails) { | ||
| return BaseResponse.success(reviewTranslationService.translateReview(reviewId, language)); | ||
| } |
There was a problem hiding this comment.
[작성자: 리뷰어, 날짜: 2025-05-15] 컨트롤러 메서드에서 사용되지 않는 @AuthenticationPrincipal CustomUserDetails 매개변수는 제거하여 코드를 깔끔하게 유지하는 것이 좋습니다.
@PostMapping("/{reviewId}/translate")
public BaseResponse<ReviewTranslationResponse> translateReview(
@Parameter(description = "reviewId") @PathVariable("reviewId") Long reviewId,
@Parameter(description = "번역 대상 언어(현재 EN만 지원)") @RequestParam Language language) {
return BaseResponse.success(reviewTranslationService.translateReview(reviewId, language));
}| @Slf4j | ||
| @RequiredArgsConstructor | ||
| @Service | ||
| @Transactional |
There was a problem hiding this comment.
메서드마다 트랜잭션 명시해주는 게 더 좋을 듯!
전체 서비스 클래스에 트랜잭션을 걸게 되면 외부 API호출 시에도 트랜잭션을 잡고 있어서
커넥션이 고갈될 수 있음
|
|
||
| #DeepL | ||
| deepl: | ||
| api-key: ${EATSSU_DEEPL_API_KEY} |
There was a problem hiding this comment.
이거 추가하면 github secret도 같이 변경해야 할 듯
#️⃣ Issue Number
📝 요약(Summary)
리뷰에 대한 DeepL 번역 기능을 추가했습니다.
POST /v2/reviews/{reviewId}/translate?language=EN을 호출하면 DeepL로 번역한 결과를 반환하고, 결과는 DB(review_translation)에 캐싱해서 같은 리뷰/언어 조합은 재호출 없이 캐시를반환합니다.
review_translation테이블 추가 (V18 마이그레이션),review_idFK에ON DELETE CASCADE걸어서 리뷰 삭제 시 캐시도 같이 삭제되도록 처리content)이 실제로 수정된 경우에만 캐시를 무효화하도록 처리 (rating만 바뀐 경우는 캐시 유지)RestTemplate빈을 별도로 분리하고 connect/read timeout을 명시적으로 설정BaseResponseStatus에 상태코드 3개 추가language=EN만 지원💬 공유사항 to 리뷰어
DeepLTranslationClient에서 기존 Apple 로그인용RestTemplate빈과 이름이 겹치지 않도록deeplRestTemplate으로 분리했습니다.✅ PR Checklist
PR이 다음 요구 사항을 충족하는지 확인하세요.