Skip to content

Commit a73b228

Browse files
author
Nick Rout
committed
Handle null match teams as TBC
1 parent 49a510b commit a73b228

File tree

2 files changed

+6
-3
lines changed

2 files changed

+6
-3
lines changed

Diff for: core/src/main/java/dev/ricknout/rugbyranker/core/api/WorldRugbyResponses.kt

+3-1
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,8 @@ data class Team(
1212
val abbreviation: String?
1313
)
1414

15+
val tbc = Team(id = -1L, name = "TBC", abbreviation = "TBC")
16+
1517
data class Entry(
1618
val pos: Int,
1719
val previousPos: Int,
@@ -61,7 +63,7 @@ data class Content(
6163
val venue: Venue?,
6264
val time: Effective,
6365
val attendance: Int,
64-
val teams: List<Team>,
66+
val teams: List<Team?>,
6567
val scores: List<Int>,
6668
val status: String,
6769
val clock: Clock?,

Diff for: match/src/main/java/dev/ricknout/rugbyranker/match/data/MatchDataConverter.kt

+3-2
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ import dev.ricknout.rugbyranker.core.api.Content
44
import dev.ricknout.rugbyranker.core.api.WorldRugbyMatchSummaryResponse
55
import dev.ricknout.rugbyranker.core.api.WorldRugbyMatchesResponse
66
import dev.ricknout.rugbyranker.core.api.WorldRugbyService
7+
import dev.ricknout.rugbyranker.core.api.tbc
78
import dev.ricknout.rugbyranker.core.model.Sport
89
import dev.ricknout.rugbyranker.core.util.DateUtils
910
import dev.ricknout.rugbyranker.match.model.Half
@@ -19,8 +20,8 @@ object MatchDataConverter {
1920
teamIds: List<Long>
2021
): List<Match> {
2122
return response.content.map { content ->
22-
val firstTeam = content.teams[0]
23-
val secondTeam = content.teams[1]
23+
val firstTeam = content.teams[0] ?: tbc
24+
val secondTeam = content.teams[1] ?: tbc
2425
val event = content.events.firstOrNull()
2526
Match(
2627
id = content.matchId,

0 commit comments

Comments
 (0)