Skip to content

Commit b23fa11

Browse files
author
이예림
committed
fix: 추천미션 리스트 사용자 필터링 추가
1 parent 99249aa commit b23fa11

File tree

2 files changed

+7
-4
lines changed

2 files changed

+7
-4
lines changed

src/main/java/com/climbup/climbup/recommendation/repository/RecommendationRepository.java

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,10 +11,8 @@
1111
public interface RecommendationRepository extends JpaRepository<ChallengeRecommendation, Long> {
1212
@Query("SELECT DISTINCT cr FROM ChallengeRecommendation cr " +
1313
"JOIN FETCH cr.mission rm " +
14-
"LEFT JOIN FETCH rm.attempts " +
1514
"JOIN FETCH rm.sector " +
1615
"WHERE cr.session = :session " +
1716
"ORDER BY cr.recommendedOrder")
1817
List<ChallengeRecommendation> findBySession(@Param("session") UserSession session);
19-
2018
}

src/main/java/com/climbup/climbup/recommendation/service/RecommendationServiceImpl.java

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -71,7 +71,9 @@ public List<RouteMissionRecommendationResponse> getRecommendationsByUserActiveSe
7171
return recommendations.stream().map(recommendation -> {
7272
RouteMission routeMission = recommendation.getMission();
7373
ClimbingGym gym = routeMission.getGym();
74-
List<UserMissionAttempt> attempts = routeMission.getAttempts().stream().toList();
74+
List<UserMissionAttempt> userAttempts = routeMission.getAttempts().stream()
75+
.filter(attempt -> attempt.getUser().getId().equals(userId))
76+
.toList();
7577
Sector sector = routeMission.getSector();
7678

7779
return RouteMissionRecommendationResponse.toDto(recommendation, routeMission, gym, attempts, sector, recommendation.getRecommendedOrder());
@@ -84,6 +86,7 @@ public List<RouteMissionRecommendationResponse> getRecommendationsByUserAttempt(
8486
UserMissionAttempt attempt = userMissionAttemptRepository.findById(attemptId).orElseThrow(AttemptNotFoundException::new);
8587

8688
UserSession session = attempt.getSession();
89+
Long userId = attempt.getUser().getId();
8790

8891
List<ChallengeRecommendation> recommendations = recommendationRepository.findBySession(session);
8992

@@ -108,7 +111,9 @@ public List<RouteMissionRecommendationResponse> getRecommendationsByUserAttempt(
108111

109112
RouteMission routeMission = recommendation.getMission();
110113
ClimbingGym gym = routeMission.getGym();
111-
List<UserMissionAttempt> attempts = routeMission.getAttempts().stream().toList();
114+
List<UserMissionAttempt> userAttempts = routeMission.getAttempts().stream()
115+
.filter(attemptRecord -> attemptRecord.getUser().getId().equals(userId))
116+
.toList();
112117
Sector sector = routeMission.getSector();
113118

114119
recommendationResponseList.add(

0 commit comments

Comments
 (0)