Skip to content

feat: 사용자 오늘 추천 없을 시 최근 추천 5개 노출#23

Merged
Suhyeon7 merged 4 commits intodevelopfrom
feat/recent-recommendations
Jan 10, 2026
Merged

feat: 사용자 오늘 추천 없을 시 최근 추천 5개 노출#23
Suhyeon7 merged 4 commits intodevelopfrom
feat/recent-recommendations

Conversation

@Suhyeon7
Copy link
Collaborator

작업 내용

  • 오늘 추천이 없으면 최근 5개 추천 조회 로직 추가

변경 사항

관련 이슈

closes #

@gemini-code-assist
Copy link

Summary of Changes

Hello @Suhyeon7, 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은 사용자 경험을 개선하기 위해 추천 시스템의 동작 방식을 업데이트합니다. 기존에는 오늘의 추천이 준비되지 않았을 때 "대기 중" 상태를 반환했지만, 이제는 사용자에게 오늘의 추천이 없을 경우 자동으로 가장 최근의 추천 5개를 보여주도록 변경되었습니다. 이는 사용자가 항상 관련성 있는 콘텐츠를 볼 수 있도록 보장하며, 시스템이 추천을 생성하는 동안에도 유용한 정보를 제공합니다. 또한, 사용자 메모리 조회 시 데이터가 없을 경우 명확한 예외를 발생시키도록 처리되었습니다.

Highlights

  • 오늘의 추천 대체 로직 추가: 사용자에게 오늘의 추천이 없을 경우, 최근 5개의 추천을 조회하여 제공하는 로직이 RecommendationService에 추가되었습니다.
  • 추천 저장소 기능 확장: RecommendationRepository에 사용자 ID와 페이지네이션 정보를 기반으로 추천 목록을 조회하는 새로운 메서드가 추가되었습니다.
  • 메모리 조회 예외 처리: HappyMemoryService에서 사용자의 메모리가 없을 경우 MEMORY_NOT_FOUND 예외를 발생시키도록 변경되었습니다.
  • 새로운 에러 코드 정의: MEMORY_NOT_FOUND라는 새로운 에러 코드가 ErrorCode enum에 추가되었습니다.
Ignored Files
  • Ignored by pattern: .github/workflows/** (1)
    • .github/workflows/deploy.yml
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.

@Suhyeon7 Suhyeon7 merged commit 49b0a1e into develop Jan 10, 2026
1 check passed
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은 사용자의 오늘 추천이 없을 경우 최근 5개의 추천을 보여주는 기능을 추가하는 것을 목표로 하고 있습니다. 전반적으로 좋은 시도이지만, 몇 가지 개선할 점이 보입니다. HappyMemoryService에서는 메모리가 없을 때 예외를 던지는 대신 빈 목록을 반환하는 것이 API 설계 관점에서 더 좋습니다. RecommendationService에서는 특정 날짜의 추천을 조회할 때 의도치 않게 최근 추천이 반환되는 로직 오류가 있으며, 코드 중복도 발견되었습니다. 자세한 내용은 각 파일에 남긴 코멘트를 참고해주세요.

Comment on lines +77 to 83
if (recommendations.isEmpty()) {
log.info("[RecommendationService.getRecommendationsByDate] returning last 5 recommendations");
recommendations = recommendationRepository.findByUserId(
userId,
PageRequest.of(0, 5, Sort.by(Sort.Direction.DESC, "createdAt"))
);
}

Choose a reason for hiding this comment

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

high

특정 날짜(recommendDate)의 추천 내역이 없을 때 항상 최근 5개의 추천을 보여주는 현재 로직은 사용자가 과거 날짜를 조회할 때 혼란을 줄 수 있습니다. 예를 들어, 어제의 추천 기록을 보려 할 때 어제 추천이 없었다면 최근 추천(오늘 추천 등)이 표시될 수 있습니다.

요청된 날짜가 오늘(LocalDate.now())이고 추천 내역이 없을 때만 최근 5개를 보여주도록 수정하는 것이 좋겠습니다. 이렇게 하면 과거 날짜에 대한 조회는 의도대로 비어있는 목록을 반환하게 됩니다.

Suggested change
if (recommendations.isEmpty()) {
log.info("[RecommendationService.getRecommendationsByDate] returning last 5 recommendations");
recommendations = recommendationRepository.findByUserId(
userId,
PageRequest.of(0, 5, Sort.by(Sort.Direction.DESC, "createdAt"))
);
}
if (recommendations.isEmpty() && recommendDate.equals(LocalDate.now())) {
log.info("[RecommendationService.getRecommendationsByDate] returning last 5 recommendations as today's are not available");
recommendations = recommendationRepository.findByUserId(
userId,
PageRequest.of(0, 5, Sort.by(Sort.Direction.DESC, "createdAt"))
);
}

Comment on lines +92 to +94
if (memories.isEmpty()) {
throw new CustomException(ErrorCode.MEMORY_NOT_FOUND);
}

Choose a reason for hiding this comment

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

medium

목록을 조회하는 API에서 결과가 없는 경우, 예외를 발생시키기보다는 빈 리스트를 반환하는 것이 일반적인 설계입니다. 클라이언트 측에서 불필요한 예외 처리를 줄일 수 있고, 데이터가 없는 상태를 정상적인 응답으로 다룰 수 있습니다. 따라서 이 부분의 예외 처리 로직을 제거하는 것을 권장합니다.

Comment on lines 50 to 57
if (recommendations.isEmpty()) {
log.info("[RecommendationService.getRecommendations] returning PENDING status");
return RecommendationListResponse.pending();
// 오늘 추천 없으면 최근 5개를 createdAt 내림차순으로 가져오기
log.info("[RecommendationService.getRecommendations] returning last 5 recommendations");
recommendations = recommendationRepository.findByUserId(
userId,
PageRequest.of(0, 5, Sort.by(Sort.Direction.DESC, "createdAt"))
);
}

Choose a reason for hiding this comment

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

medium

최근 5개의 추천을 가져오는 로직이 getRecommendations 메소드와 getRecommendationsByDate 메소드에서 중복되고 있습니다. 코드의 유지보수성을 높이기 위해 이 로직을 별도의 private 헬퍼 메소드로 추출하는 것을 권장합니다. 예를 들어, findRecentRecommendations(Long userId)와 같은 메소드를 만들어 재사용할 수 있습니다.

FILE_SIZE_EXCEEDED(HttpStatus.PAYLOAD_TOO_LARGE, "FILE_413", "파일 크기가 허용 용량을 초과했습니다."),
MAX_IMAGE_EXCEEDED(HttpStatus.BAD_REQUEST, "MEMORY_004", "이미지는 최대 4개까지만 업로드 가능합니다"),
INVALID_CANDY_COLOR(HttpStatus.BAD_REQUEST, "CANDY_401", "캔디 색상은 YELLOW, ORANGE, PINK, GREEN, BLUE 중 하나여야 합니다."),
MEMORY_NOT_FOUND(HttpStatus.NOT_FOUND, "MEMORY_404", "사용자의 메모리를 찾을 수 없습니다."),

Choose a reason for hiding this comment

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

medium

HappyMemoryService에 대한 다른 리뷰 의견(결과가 없을 때 예외 대신 빈 리스트 반환)을 반영할 경우, 이 MEMORY_NOT_FOUND 에러 코드는 사용되지 않을 수 있습니다. 만약 다른 곳에서 사용될 계획이 없다면, 불필요한 코드가 되므로 제거하는 것을 고려해 보세요.

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.

2 participants