Skip to content

Commit

Permalink
[MERGE] HOTFIX 내용 dev에도 반영 (#451)
Browse files Browse the repository at this point in the history
  • Loading branch information
kseysh authored Nov 19, 2024
2 parents 59ad7ae + 7cdb49d commit 1ed0b55
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 30 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -24,7 +25,8 @@ public class FriendRecommender {
private final FriendService friendService;
private final PlaygroundUserIdsProvider playgroundUserIdsProvider;

public RecommendedFriendsRequest recommendFriendsByTypeList(List<FriendRecommendType> typeList, int size, User user) {
public RecommendedFriendsRequest recommendFriendsByTypeList(List<FriendRecommendType> typeList, int size,
User user) {
typeList = this.adjustTypeList(typeList);

OwnPlaygroundProfile ownProfile = playgroundAuthService.getOwnPlaygroundProfile(user.getPlaygroundToken());
Expand Down Expand Up @@ -58,22 +60,17 @@ private List<SimplePokeProfile> convertUserProfilesToSimplePokeProfiles(
}

private List<SimplePokeProfile> makeSimplePokeProfilesForNotFriend(
List<PlaygroundProfile> playgroundProfiles, List<UserProfile> 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();
List<PlaygroundProfile> playgroundProfiles, List<UserProfile> userProfiles
) {
return userProfiles.stream()
.map(userProfile -> playgroundProfiles.stream()
.filter(profile -> profile.getMemberId().equals(userProfile.getPlaygroundId()))
.findFirst()
.map(playgroundProfile ->
SimplePokeProfile.createNonFriendPokeProfile(playgroundProfile, userProfile))
)
.filter(Optional::isPresent).map(Optional::get)
.toList();
}

private List<UserProfile> getRecommendableUserProfiles(
Expand All @@ -84,7 +81,8 @@ private List<UserProfile> getRecommendableUserProfiles(
} else {
playgroundIds = playgroundUserIdsProvider.findPlaygroundIdsByType(ownProfile, type);
}
List<UserProfile> unFilteredUserProfiles = userService.getUserProfilesByPlaygroundIds(List.copyOf(playgroundIds));
List<UserProfile> unFilteredUserProfiles = userService.getUserProfilesByPlaygroundIds(
List.copyOf(playgroundIds));
return friendFilter.excludeAlreadyFriendUserIds(unFilteredUserProfiles);
}

Expand Down
21 changes: 9 additions & 12 deletions src/main/java/org/sopt/app/presentation/poke/PokeResponse.java
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand Down Expand Up @@ -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,
"",
"",
Expand Down

0 comments on commit 1ed0b55

Please sign in to comment.