Skip to content

Commit

Permalink
[ADD] 횟수 관련 필드 추가
Browse files Browse the repository at this point in the history
  • Loading branch information
thguss committed Jan 13, 2025
1 parent 802daaf commit 3735183
Showing 1 changed file with 9 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -23,9 +23,13 @@ public record AchievedThemeResponse(
@NotNull
@Schema(description = "테마 이름", example = "관계쌓기")
String name,
@Schema(description = "전체 루틴 달성 횟수", example = "10")
int routineTotalCount,
@NotNull
@Schema(description = "루틴 목록")
List<AchievedRoutine> routines,
@Schema(description = "전체 챌린지 달성 횟수", example = "10")
int challengeTotalCount,
@NotNull
@Schema(description = "챌린지 목록")
List<AchievedChallenge> challenges
Expand All @@ -38,16 +42,21 @@ public static AchievedThemeResponse of(
List<MemberChallenge> memberChallenges,
Map<Long, Challenge> challengeMapOfMember
) {
val routineTotalCount = memberRoutines.stream().mapToInt(MemberRoutine::getAchievementCount).sum();
val challengeTotalCount = memberChallenges.stream().mapToInt(MemberChallenge::getAchievedCount).sum();

return AchievedThemeResponse.builder()
.id(theme.getId())
.name(theme.getName())
.routineTotalCount(routineTotalCount)
.routines(memberRoutines.stream()
.map(it -> AchievedRoutine.of(routineMapOfMember.get(it.getId()), it))
.sorted((a, b) -> {
val diff = b.achievedCount - a.achievedCount;
return diff != 0 ? diff : a.content.compareTo(b.content);
})
.toList())
.challengeTotalCount(challengeTotalCount)
.challenges(memberChallenges.stream()
.map(it -> AchievedChallenge.of(challengeMapOfMember.get(it.getId()), it))
.sorted((a, b) -> {
Expand Down

0 comments on commit 3735183

Please sign in to comment.