From 9fb3304d2bc67bb1c3c74d6bd08645f0816e0925 Mon Sep 17 00:00:00 2001 From: kseysh Date: Mon, 18 Nov 2024 00:45:55 +0900 Subject: [PATCH 1/2] =?UTF-8?q?[hotfix]=20=ED=94=8C=EB=A0=88=EC=9D=B4?= =?UTF-8?q?=EA=B7=B8=EB=9D=BC=EC=9A=B4=EB=93=9C=EC=95=84=EC=9D=B4=EB=94=94?= =?UTF-8?q?=EA=B0=80=20=EC=9C=A0=ED=9A=A8=ED=95=98=EC=A7=80=20=EC=95=8A?= =?UTF-8?q?=EC=9D=80=20=EC=B9=9C=EA=B5=AC=20=EC=B6=94=EC=B2=9C=EC=8B=9C=20?= =?UTF-8?q?=EC=97=90=EB=9F=AC=20=EB=B0=9C=EC=83=9D=20=EC=98=A4=EB=A5=98=20?= =?UTF-8?q?=ED=95=B4=EA=B2=B0=20(#449)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../application/friend/FriendRecommender.java | 37 +++++++++++-------- 1 file changed, 21 insertions(+), 16 deletions(-) diff --git a/src/main/java/org/sopt/app/application/friend/FriendRecommender.java b/src/main/java/org/sopt/app/application/friend/FriendRecommender.java index 8827e265..44ce7637 100644 --- a/src/main/java/org/sopt/app/application/friend/FriendRecommender.java +++ b/src/main/java/org/sopt/app/application/friend/FriendRecommender.java @@ -2,6 +2,7 @@ import java.util.ArrayList; import java.util.List; +import java.util.Optional; import java.util.Set; import lombok.RequiredArgsConstructor; import org.sopt.app.application.playground.PlaygroundAuthService; @@ -24,7 +25,8 @@ public class FriendRecommender { private final FriendService friendService; private final PlaygroundUserIdsProvider playgroundUserIdsProvider; - public RecommendedFriendsRequest recommendFriendsByTypeList(List typeList, int size, User user) { + public RecommendedFriendsRequest recommendFriendsByTypeList(List typeList, int size, + User user) { typeList = this.adjustTypeList(typeList); OwnPlaygroundProfile ownProfile = playgroundAuthService.getOwnPlaygroundProfile(user.getPlaygroundToken()); @@ -60,20 +62,22 @@ private List convertUserProfilesToSimplePokeProfiles( private List makeSimplePokeProfilesForNotFriend( List playgroundProfiles, List userProfiles) { - return userProfiles.stream().map(userProfile -> { - PlaygroundProfile playgroundProfile = playgroundProfiles.stream() - .filter(profile -> profile.getMemberId().equals(userProfile.getPlaygroundId())) - .findFirst().orElseThrow(); - - return SimplePokeProfile.createNonFriendPokeProfile( - userProfile.getUserId(), - userProfile.getPlaygroundId(), - playgroundProfile.getProfileImage(), - userProfile.getName(), - playgroundProfile.getLatestActivity().getGeneration(), - playgroundProfile.getLatestActivity().getPlaygroundPart().getPartName() - ); - }).toList(); + return userProfiles.stream() + .map(userProfile -> playgroundProfiles.stream() + .filter(profile -> profile.getMemberId().equals(userProfile.getPlaygroundId())) + .findFirst() + .map(playgroundProfile -> SimplePokeProfile.createNonFriendPokeProfile( + userProfile.getUserId(), + userProfile.getPlaygroundId(), + playgroundProfile.getProfileImage(), + userProfile.getName(), + playgroundProfile.getLatestActivity().getGeneration(), + playgroundProfile.getLatestActivity().getPlaygroundPart().getPartName() + )) + ) + .filter(Optional::isPresent) + .map(Optional::get) + .toList(); } private List getRecommendableUserProfiles( @@ -84,7 +88,8 @@ private List getRecommendableUserProfiles( } else { playgroundIds = playgroundUserIdsProvider.findPlaygroundIdsByType(ownProfile, type); } - List unFilteredUserProfiles = userService.getUserProfilesByPlaygroundIds(List.copyOf(playgroundIds)); + List unFilteredUserProfiles = userService.getUserProfilesByPlaygroundIds( + List.copyOf(playgroundIds)); return friendFilter.excludeAlreadyFriendUserIds(unFilteredUserProfiles); } From 180fa43aca205c3e5e1f83e7726cf9e8a417290c Mon Sep 17 00:00:00 2001 From: kseysh Date: Mon, 18 Nov 2024 00:50:38 +0900 Subject: [PATCH 2/2] =?UTF-8?q?[refactor]=20DTO=20=EB=B3=80=EA=B2=BD=20?= =?UTF-8?q?=EC=8B=9C=20=ED=8C=A9=ED=86=A0=EB=A6=AC=20=EB=A9=94=EC=84=9C?= =?UTF-8?q?=EB=93=9C=EB=A1=9C=20=EA=B0=80=EB=8F=85=EC=84=B1=20=ED=96=A5?= =?UTF-8?q?=EC=83=81=20(#449)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../application/friend/FriendRecommender.java | 17 +++++---------- .../app/presentation/poke/PokeResponse.java | 21 ++++++++----------- 2 files changed, 14 insertions(+), 24 deletions(-) diff --git a/src/main/java/org/sopt/app/application/friend/FriendRecommender.java b/src/main/java/org/sopt/app/application/friend/FriendRecommender.java index 44ce7637..55990ddc 100644 --- a/src/main/java/org/sopt/app/application/friend/FriendRecommender.java +++ b/src/main/java/org/sopt/app/application/friend/FriendRecommender.java @@ -60,23 +60,16 @@ private List convertUserProfilesToSimplePokeProfiles( } private List makeSimplePokeProfilesForNotFriend( - List playgroundProfiles, List userProfiles) { - + List playgroundProfiles, List userProfiles + ) { return userProfiles.stream() .map(userProfile -> playgroundProfiles.stream() .filter(profile -> profile.getMemberId().equals(userProfile.getPlaygroundId())) .findFirst() - .map(playgroundProfile -> SimplePokeProfile.createNonFriendPokeProfile( - userProfile.getUserId(), - userProfile.getPlaygroundId(), - playgroundProfile.getProfileImage(), - userProfile.getName(), - playgroundProfile.getLatestActivity().getGeneration(), - playgroundProfile.getLatestActivity().getPlaygroundPart().getPartName() - )) + .map(playgroundProfile -> + SimplePokeProfile.createNonFriendPokeProfile(playgroundProfile, userProfile)) ) - .filter(Optional::isPresent) - .map(Optional::get) + .filter(Optional::isPresent).map(Optional::get) .toList(); } diff --git a/src/main/java/org/sopt/app/presentation/poke/PokeResponse.java b/src/main/java/org/sopt/app/presentation/poke/PokeResponse.java index c3e11bf9..1de3e9c6 100755 --- a/src/main/java/org/sopt/app/presentation/poke/PokeResponse.java +++ b/src/main/java/org/sopt/app/presentation/poke/PokeResponse.java @@ -3,7 +3,9 @@ import io.swagger.v3.oas.annotations.media.Schema; import java.util.List; import lombok.*; +import org.sopt.app.application.playground.dto.PlaygroundProfileInfo.PlaygroundProfile; import org.sopt.app.application.poke.PokeInfo.*; +import org.sopt.app.application.user.UserProfile; import org.sopt.app.domain.enums.FriendRecommendType; import org.sopt.app.common.utils.AnonymousImageGenerator; @@ -196,21 +198,16 @@ public static SimplePokeProfile of( } public static SimplePokeProfile createNonFriendPokeProfile( - Long userId, - Long playgroundId, - String profileImage, - String name, - Long generation, - String part + PlaygroundProfile playgroundProfile, UserProfile userProfile ) { return new SimplePokeProfile( - userId, - playgroundId, - profileImage == null ? "" : profileImage, - name, + userProfile.getUserId(), + userProfile.getPlaygroundId(), + playgroundProfile.getProfileImage() == null ? "" : playgroundProfile.getProfileImage(), + userProfile.getName(), "", - generation, - part, + playgroundProfile.getLatestActivity().getGeneration(), + playgroundProfile.getLatestActivity().getPlaygroundPart().getPartName(), 0, "", "",