Skip to content
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
35 changes: 22 additions & 13 deletions src/main/java/org/sopt/app/presentation/user/UserController.java
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,9 @@
import java.util.ArrayList;
import java.util.Comparator;
import java.util.List;
import java.util.Optional;
import java.util.stream.Collectors;

import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import lombok.val;
Expand Down Expand Up @@ -103,31 +106,37 @@ public ResponseEntity<UserResponse.SoptLog> getUserSoptLog(
PlaygroundProfile playgroundProfile = authFacade.getUserDetails(user);
Long soptampRank = null;
Long soptDuring = null;
Boolean isActive = playgroundProfile.getLatestActivity().getGeneration().equals(generation);

Optional<Long> latestGeneration = playgroundProfile.getAllActivities().stream()
.filter(c -> !c.getPlaygroundPart().getPartName().equals("미상"))
.map(PlaygroundProfileInfo.ActivityCardinalInfo::getGeneration)
.max(Comparator.naturalOrder());

Boolean isActive = latestGeneration.isPresent() && latestGeneration.get().equals(generation);

boolean isFortuneChecked = fortuneService.isExistTodayFortune((user.getId()));
String fortuneText = isFortuneChecked?fortuneService.getTodayFortuneWordByUserId(user.getId(), LocalDate.now()).title():"오늘 내 운세는?";

// if (isActive) {
// // soptampRank = rankFacade.findUserRank(user.getId());
// } else {
//
// }
if (Boolean.TRUE.equals(isActive)) {
soptampRank = rankFacade.findUserRank(user.getId());
} else {
List<Long> generations = playgroundProfile.getAllActivities().stream()
.map(PlaygroundProfileInfo.ActivityCardinalInfo::getGeneration)
.toList();

List<Long> generations = playgroundProfile.getAllActivities().stream()
.map(PlaygroundProfileInfo.ActivityCardinalInfo::getGeneration)
.toList();

if (!generations.isEmpty()) {
soptDuring = (long) ActivityDurationCalculator.calculate(generations);
if (!generations.isEmpty()) {
soptDuring = (long) ActivityDurationCalculator.calculate(generations);
}
}

List<String> icons = authFacade.getIcons(isActive ? IconType.ACTIVE : IconType.INACTIVE);
List<String> icons = authFacade.getIcons(Boolean.TRUE.equals(isActive) ? IconType.ACTIVE : IconType.INACTIVE);
List<String> iconsMutableList = new ArrayList<>(icons);
List<String> iconPriority = List.of("sop-level", "poke", "soptamp", "duration");
iconsMutableList.sort(Comparator.comparingInt(s -> {
String iconName = s.replaceAll("^" + s3BaseUrl + "sopt-log/|.png$", "");
return iconPriority.indexOf(iconName);
}));

return ResponseEntity.ok(
SoptLog.of(soptLevel, pokeCount, soptampRank, soptDuring, isActive, iconsMutableList, playgroundProfile,
partTypeToKorean,isFortuneChecked, fortuneText));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -169,12 +169,12 @@ public static SoptLog of(int soptLevel, Long pokeCount, Long soptampRank, Long d
return SoptLog.builder()
.soptLevel("Lv." + soptLevel)
.pokeCount(pokeCount + "회")
// 솝탬프 오픈 전까지는 순위 부분에 공개 예정! 표시
.soptampRank(soptampRank != null ? soptampRank + "등" : "공개 예정!")
.userName(playgroundProfile.getName())
.profileImage(playgroundProfile.getProfileImage() != null ? playgroundProfile.getProfileImage() : "")
.part(playgroundProfile.getAllActivities().stream()
.map(c -> c.getPlaygroundPart().getPartName())
.filter(c -> !c.equals("미상"))
.collect(Collectors.joining("/")))
.profileMessage(playgroundProfile.getIntroduction() != null ? playgroundProfile.getIntroduction() : "")
.during(during != null ? during + "개월" : "")
Expand Down