Skip to content

Commit cc40704

Browse files
committed
Merge remote-tracking branch 'origin/main' into prod
2 parents e1551d6 + 5c8af85 commit cc40704

File tree

2 files changed

+9
-6
lines changed

2 files changed

+9
-6
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: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -71,10 +71,12 @@ 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

77-
return RouteMissionRecommendationResponse.toDto(recommendation, routeMission, gym, attempts, sector, recommendation.getRecommendedOrder());
79+
return RouteMissionRecommendationResponse.toDto(recommendation, routeMission, gym, userAttempts, sector, recommendation.getRecommendedOrder());
7880
}).toList();
7981
}
8082

@@ -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,11 +111,13 @@ 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(
115-
RouteMissionRecommendationResponse.toDto(recommendation, routeMission, gym, attempts, sector, recommendation.getRecommendedOrder())
120+
RouteMissionRecommendationResponse.toDto(recommendation, routeMission, gym, userAttempts, sector, recommendation.getRecommendedOrder())
116121
);
117122

118123
startingIndex++;

0 commit comments

Comments
 (0)