Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

deploy to prd #78

Merged
merged 2 commits into from
Oct 16, 2023
Merged
Show file tree
Hide file tree
Changes from all 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
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
Loading