Skip to content

Commit

Permalink
Merge pull request #78 from SWM-KAWAI-MANS/develop
Browse files Browse the repository at this point in the history
deploy to prd
  • Loading branch information
seong-wooo authored Oct 16, 2023
2 parents 3be3256 + aeb2771 commit 276c43c
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
import java.time.Duration;
import java.time.LocalDateTime;
import java.util.List;
import java.util.Objects;

public record MyPageRunningResponse(String id,
LocalDateTime startTime,
Expand All @@ -17,8 +18,17 @@ public record MyPageRunningResponse(String id,

public static MyPageRunningResponse of(Battle battle, String memberId) {
final RunnerRecord runnerRecentRecord = battle.getRunnerRecentRecord(memberId);

final LocalDateTime startTime = battle.getStartTime();

if (Objects.isNull(runnerRecentRecord)) {
return new MyPageRunningResponse(
battle.getId(),
startTime,
new RunningTimeResponse(0, 0, 0),
0
);
}

final LocalDateTime endTime = runnerRecentRecord.getTime();
final Duration duration = Duration.between(startTime, endTime);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@

import java.time.Duration;
import java.util.List;
import java.util.Objects;

public record MyPageTotalResponse(double totalDistance, double averagePace, RunningTimeResponse totalRunningTime) {

Expand All @@ -31,11 +32,11 @@ public static MyPageTotalResponse of(String memberId, List<Battle> battles, List
final long totalBattleRunningTime = battles.stream()
.mapToLong(
battle -> {
try {
return Duration.between(battle.getCreatedAt(), battle.getRunnerRecentRecord(memberId).getTime()).toSeconds();
} catch (InvalidRecentRunnerRecordException exception) {
final RunnerRecord runnerRecentRecord = battle.getRunnerRecentRecord(memberId);
if (Objects.isNull(runnerRecentRecord)) {
return 0;
}
return Duration.between(battle.getCreatedAt(), runnerRecentRecord.getTime()).toSeconds();
}
)
.sum();
Expand Down

0 comments on commit 276c43c

Please sign in to comment.