Skip to content

Conversation

@eric-jy-park
Copy link
Member

📌 PR 제목

📋 작업 내용

  • feat: 세션 생성 시 루트미션 추천 만들어지는 부분 구현

✅ 체크리스트

  • 테스트를 완료했나요?
  • 코드 컨벤션을 지켰나요?
  • 관련 문서를 업데이트 했나요?

🚨 주의사항

  • 일단 기능은 개발했지만, 성능 최적화랑 코드 구조를 개선해야합니다.
  • 클로드 코드 리뷰 받고, 마저 커밋 올릴게용

@eric-jy-park eric-jy-park requested a review from Copilot July 31, 2025 13:59
@eric-jy-park eric-jy-park self-assigned this Jul 31, 2025
@claude
Copy link

claude bot commented Jul 31, 2025

Claude finished @eric-jy-park's task —— View job


코드 리뷰 완료

할 일 목록:

  • 변경된 파일들 분석
  • 코드 리뷰 및 피드백 작성
  • 최종 리뷰 결과 업데이트

리뷰 요약

세션 생성 시 루트미션 추천 기능이 구현되었습니다. 기본적인 구조는 잘 설계되었으나, 성능과 데이터 검증 측면에서 개선이 필요합니다. 특히 findAll() 사용과 N+1 쿼리 문제가 주요 이슈입니다.

구분 내용
핵심 기능 세션 생성 시 자동 추천 생성, 사용자별 추천 조회
주요 변경사항 RecommendationService 구현, 새 Repository 추가, TestController에 더미데이터
개선 필요 성능 최적화, 데이터 검증, 페이징 처리

코드 리뷰

RecommendationServiceImpl.java:37 - issue: findAll() 사용으로 인한 성능 문제 - 모든 루트미션을 메모리에 로드하면 데이터가 많아질 때 심각한 성능 저하 발생, 페이징이나 배치 처리로 개선 필요

RecommendationServiceImpl.java:42-44 - issue: N+1 쿼리 문제 - 각 루트미션마다 attempts를 별도 조회하여 성능 저하, fetch join 사용하여 한 번에 로드 필요

RecommendationServiceImpl.java:56 - issue: 하드코딩된 추천 개수 제한 - 30개로 고정되어 있어 유연성 부족, 설정값이나 파라미터로 변경 필요

RecommendationServiceImpl.java:72-74 - suggestion: 중복된 필터링 로직 - 이미 추천 생성 시 필터링했으나 조회 시 다시 필터링, 불필요한 연산 제거 고려

UserMissionAttemptRequest.java:10 - issue: 잘못된 validation 어노테이션 - Long 타입에 @NotBlank 사용, @NotNull 사용해야 함

AttemptController.java:65 - issue: 빈 객체 반환 - 실제 구현 없이 빈 응답 객체만 반환, 임시 구현이라도 적절한 에러 메시지나 구현 예정 안내 필요


Copy link

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull Request Overview

세션 생성 시 루트미션 추천 시스템을 구축하는 기능을 구현하였습니다. 사용자가 새로운 세션을 시작할 때 자동으로 해당 사용자에게 맞는 루트미션 추천을 생성합니다.

  • 세션 생성 시점에 추천 로직이 자동으로 실행되도록 통합
  • 사용자가 시도하지 않은 루트미션을 필터링하여 최대 30개 추천 생성
  • 추천 데이터 조회를 위한 REST API 엔드포인트 구현

Reviewed Changes

Copilot reviewed 12 out of 12 changed files in this pull request and generated 6 comments.

Show a summary per file
File Description
application.yaml Hibernate DDL 설정을 create에서 update로 변경
TestController.java 테스트 데이터 생성에 섹터와 루트미션 데이터 추가
UserSessionServiceImpl.java 세션 생성 시 추천 서비스 호출 로직 추가
RecommendationServiceImpl.java 세션별 추천 생성 및 조회 로직 구현
RecommendationController.java 추천 조회 API 엔드포인트 구현
Repository files 섹터와 루트미션을 위한 기본 JPA 레포지토리 추가
AttemptController.java 도전 기록 생성 API 스켈레톤 추가


@Data
public class UserMissionAttemptRequest {
@NotBlank
Copy link

Copilot AI Jul 31, 2025

Choose a reason for hiding this comment

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

The @notblank annotation is incorrect for Long type. @notblank is for String validation. Use @NotNull instead for Long fields.

Suggested change
@NotBlank
@NotNull

Copilot uses AI. Check for mistakes.
})
.toList();

recommendations = recommendations.subList(0, (int) Math.min(30, (long) recommendations.size()));
Copy link

Copilot AI Jul 31, 2025

Choose a reason for hiding this comment

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

The magic number 30 should be extracted as a constant or configuration parameter for better maintainability and consistency across the codebase.

Suggested change
recommendations = recommendations.subList(0, (int) Math.min(30, (long) recommendations.size()));
recommendations = recommendations.subList(0, (int) Math.min(MAX_RECOMMENDATIONS, (long) recommendations.size()));

Copilot uses AI. Check for mistakes.

private final RecommendationService recommendationService;
private final UserSessionService userSessionService;
private final UserSessionRepository userSessionRepository;
Copy link

Copilot AI Jul 31, 2025

Choose a reason for hiding this comment

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

The userSessionRepository field is injected but never used in this controller. Consider removing unused dependencies to improve code clarity.

Suggested change
private final UserSessionRepository userSessionRepository;

Copilot uses AI. Check for mistakes.
public class RecommendationController {

private final RecommendationService recommendationService;
private final UserSessionService userSessionService;
Copy link

Copilot AI Jul 31, 2025

Choose a reason for hiding this comment

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

The userSessionService field is injected but never used in this controller. Consider removing unused dependencies to improve code clarity.

Suggested change
private final UserSessionService userSessionService;

Copilot uses AI. Check for mistakes.
public void generateRecommendationsForSession(UserSession session){
User user = session.getUser();

List<RouteMission> routeMissions = routeMissionRepository.findAll();
Copy link

Copilot AI Jul 31, 2025

Choose a reason for hiding this comment

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

Loading all route missions into memory with findAll() can cause performance issues as the dataset grows. Consider implementing pagination or filtering at the database level.

Copilot uses AI. Check for mistakes.

List<ChallengeRecommendation> recommendations = routeMissions.stream()
.filter(routeMission ->
routeMission.getAttempts().stream().noneMatch(userMissionAttempt -> userMissionAttempt.getUser().getId().equals(user.getId()))
Copy link

Copilot AI Jul 31, 2025

Choose a reason for hiding this comment

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

This filtering logic creates an N+1 query problem. Each route mission will trigger a separate query to load attempts. Consider using a custom query with JOIN to fetch non-attempted missions efficiently.

Copilot uses AI. Check for mistakes.
@eric-jy-park eric-jy-park force-pushed the feat/9-routemission-recommendation branch from 6478e0b to e5782a0 Compare August 1, 2025 09:40
@claude
Copy link

claude bot commented Aug 1, 2025

Claude finished @eric-jy-park's task —— View job


할 일 목록:

  • 변경된 파일들 분석
  • 코드 리뷰 및 피드백 작성
  • 최종 리뷰 결과 업데이트

리뷰 요약

세션 생성 시 루트미션 추천 기능이 구현되었습니다. 기본적인 구조는 잘 설계되었으나, 성능과 데이터 검증 측면에서 개선이 필요합니다. 특히 findAll() 사용과 N+1 쿼리 문제가 주요 이슈입니다.

구분 내용
핵심 기능 세션 생성 시 자동 추천 생성, 사용자별 추천 조회
주요 변경사항 RecommendationService 구현, 새 Repository 추가, TestController에 더미데이터
개선 필요 성능 최적화, 데이터 검증, 페이징 처리

코드 리뷰

RecommendationServiceImpl.java:37 - issue: findAll() 사용으로 인한 성능 문제 - 모든 루트미션을 메모리에 로드하면 데이터가 많아질 때 심각한 성능 저하 발생, 페이징이나 배치 처리로 개선 필요

RecommendationServiceImpl.java:42-44 - issue: N+1 쿼리 문제 - 각 루트미션마다 attempts를 별도 조회하여 성능 저하, fetch join 사용하여 한 번에 로드 필요

RecommendationServiceImpl.java:56 - issue: 하드코딩된 추천 개수 제한 - 30개로 고정되어 있어 유연성 부족, 설정값이나 파라미터로 변경 필요

RecommendationServiceImpl.java:72-74 - suggestion: 중복된 필터링 로직 - 이미 추천 생성 시 필터링했으나 조회 시 다시 필터링, 불필요한 연산 제거 고려

UserMissionAttemptRequest.java:10 - issue: 잘못된 validation 어노테이션 - Long 타입에 @NotBlank 사용, @NotNull 사용해야 함

AttemptController.java:65 - issue: 빈 객체 반환 - 실제 구현 없이 빈 응답 객체만 반환, 임시 구현이라도 적절한 에러 메시지나 구현 예정 안내 필요


@claude
Copy link

claude bot commented Aug 1, 2025

Claude finished @eric-jy-park's task —— View job


할 일 목록:

  • 변경된 파일들 분석
  • 코드 리뷰 및 피드백 작성
  • 최종 리뷰 결과 업데이트

리뷰 요약

세션 생성 시 루트미션 추천 기능이 구현되었습니다. 기본적인 구조는 잘 설계되었으나, 성능과 데이터 검증 측면에서 개선이 필요합니다. 특히 findUnattemptedRouteMissionsByUser 쿼리와 N+1 쿼리 문제가 주요 이슈입니다.

구분 내용
핵심 기능 세션 생성 시 자동 추천 생성, 사용자별 추천 조회
주요 변경사항 RecommendationService 구현, 새 Repository 추가, TestController에 더미데이터
개선 필요 성능 최적화, 데이터 검증, 페이징 처리

코드 리뷰

RecommendationServiceImpl.java:53 - issue: 하드코딩된 추천 개수 제한 - 30개로 고정되어 있어 유연성 부족, 설정값이나 파라미터로 변경 필요

RecommendationServiceImpl.java:67 - issue: N+1 쿼리 문제 - 각 루트미션마다 attempts를 별도 조회하여 성능 저하, fetch join 사용하여 한 번에 로드 필요

RecommendationController.java:33-34 - suggestion: 사용하지 않는 의존성 - userSessionService와 userSessionRepository가 주입되었으나 사용되지 않음, 불필요한 의존성 제거 고려

AttemptController.java:109 - issue: 빈 객체 반환 - 실제 구현 없이 빈 응답 객체만 반환, 임시 구현이라도 적절한 에러 메시지나 구현 예정 안내 필요


@claude
Copy link

claude bot commented Aug 1, 2025

Claude finished @eric-jy-park's task —— View job


할 일 목록:

  • 변경된 파일들 분석
  • 코드 리뷰 및 피드백 작성
  • 최종 리뷰 결과 업데이트

리뷰 요약

세션 생성 시 루트미션 추천 기능이 구현되었습니다. 기본적인 구조는 잘 설계되었으나, 성능과 데이터 검증 측면에서 개선이 필요합니다. 특히 findUnattemptedRouteMissionsByUser 쿼리와 N+1 쿼리 문제가 주요 이슈입니다.

구분 내용
핵심 기능 세션 생성 시 자동 추천 생성, 사용자별 추천 조회
주요 변경사항 RecommendationService 구현, 새 Repository 추가, TestController에 더미데이터
개선 필요 성능 최적화, 데이터 검증, 페이징 처리

코드 리뷰

RecommendationServiceImpl.java:53 - issue: 하드코딩된 추천 개수 제한 - 30개로 고정되어 있어 유연성 부족, 설정값이나 파라미터로 변경 필요

RecommendationServiceImpl.java:67 - issue: N+1 쿼리 문제 - 각 루트미션마다 attempts를 별도 조회하여 성능 저하, fetch join 사용하여 한 번에 로드 필요

RecommendationController.java:33-34 - suggestion: 사용하지 않는 의존성 - userSessionService와 userSessionRepository가 주입되었으나 사용되지 않음, 불필요한 의존성 제거 고려

AttemptController.java:109 - issue: 빈 객체 반환 - 실제 구현 없이 빈 응답 객체만 반환, 임시 구현이라도 적절한 에러 메시지나 구현 예정 안내 필요


@eric-jy-park eric-jy-park merged commit 3c99880 into main Aug 1, 2025
1 check 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.

2 participants