Skip to content

Commit

Permalink
feat - #117 달성현황뷰 response에 챌린지 시작날짜(yyyy-MM-dd) 추가
Browse files Browse the repository at this point in the history
  • Loading branch information
jumining committed May 17, 2024
1 parent 6b3743f commit 8301f74
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ public record ChallengeResponse(
Integer period,
List<Status> statuses,
Integer todayIndex,
String startDate,
Long goalTime,
List<AppGoalTimeResponse> apps
) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@

import java.time.LocalDate;
import java.time.LocalDateTime;
import java.time.format.DateTimeFormatter;
import java.time.temporal.ChronoUnit;
import java.util.ArrayList;
import java.util.List;
Expand Down Expand Up @@ -82,13 +83,17 @@ public ChallengeResponse getChallenge(Long userId) {
Challenge challenge = findCurrentChallengeByUserId(userId);
Integer todayIndex = calculateTodayIndex(challenge.getCreatedAt(), challenge.getPeriod());

DateTimeFormatter formatter = DateTimeFormatter.ofPattern("yyyy-MM-dd");
String formattedStartDate = challenge.getCreatedAt().format(formatter);

return ChallengeResponse.builder()
.period(challenge.getPeriod())
.statuses(challenge.getHistoryDailyChallenges()
.stream()
.map(DailyChallenge::getStatus)
.toList())
.todayIndex(todayIndex)
.startDate(formattedStartDate)
.goalTime(challenge.getGoalTime())
.apps(challenge.getApps().stream()
.map(app -> new AppGoalTimeResponse(app.getAppCode(), app.getGoalTime())).toList())
Expand Down

0 comments on commit 8301f74

Please sign in to comment.