Skip to content

Commit

Permalink
fix: 기록이 없는 경우 빈 기록 반환 (#73)
Browse files Browse the repository at this point in the history
  • Loading branch information
seong-wooo authored Oct 11, 2023
1 parent 0bffcb9 commit cecd258
Showing 1 changed file with 9 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,17 @@
import online.partyrun.partyrunbattleservice.domain.battle.entity.Battle;
import online.partyrun.partyrunbattleservice.domain.single.entity.Single;

import java.util.Collections;
import java.util.List;

public record MyPageHistoryResponse(List<MyPageRunningResponse> history) {
private static final MyPageHistoryResponse EMPTY_HISTORY = new MyPageHistoryResponse(Collections.emptyList());

public static MyPageHistoryResponse ofBattles(List<Battle> battles, String memberId) {
if (battles.isEmpty()) {
return EMPTY_HISTORY;
}

return new MyPageHistoryResponse(
battles.stream()
.map(battle -> MyPageRunningResponse.of(battle, memberId))
Expand All @@ -16,6 +22,9 @@ public static MyPageHistoryResponse ofBattles(List<Battle> battles, String membe
}

public static MyPageHistoryResponse ofSingle(List<Single> singles) {
if (singles.isEmpty()) {
return EMPTY_HISTORY;
}
return new MyPageHistoryResponse(
singles.stream()
.map(MyPageRunningResponse::from)
Expand Down

0 comments on commit cecd258

Please sign in to comment.