Skip to content

Commit cc50762

Browse files
committed
Limit hourly forecasts to 24
Tomorrow.io's API returns 120 hours of forecasts, which doesn't look nice on ForecastScreenContent now.
1 parent 9fbeadd commit cc50762

File tree

2 files changed

+5
-4
lines changed

2 files changed

+5
-4
lines changed

app/src/main/java/io/github/tobyhs/weatherweight/data/TomorrowRepository.kt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ class TomorrowRepository(
2727
location = forecast.location.name,
2828
publicationTime = ZonedDateTime.now(clock),
2929
dailyForecasts = convertDailyForecasts(forecast.timelines.daily),
30-
hourlyForecasts = convertHourlyForecasts(forecast.timelines.hourly),
30+
hourlyForecasts = convertHourlyForecasts(forecast.timelines.hourly.take(24)),
3131
)
3232
}
3333

app/src/test/java/io/github/tobyhs/weatherweight/data/TomorrowRepositoryTest.kt

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -60,16 +60,16 @@ class TomorrowRepositoryTest {
6060
)
6161
)
6262
),
63-
hourly = listOf(
63+
hourly = (0L until 120).map { i ->
6464
HourlyForecast(
65-
time = time,
65+
time = time.plusHours(i),
6666
values = HourlyForecastValues(
6767
temperature = 67.0,
6868
precipitationProbability = 2,
6969
weatherCode = 2000,
7070
)
7171
)
72-
)
72+
}
7373
),
7474
location = Location(name = "San Francisco, California, United States")
7575
)
@@ -95,5 +95,6 @@ class TomorrowRepositoryTest {
9595
temperature = 67,
9696
precipitationProbability = 2,
9797
)))
98+
assertThat(result.hourlyForecasts.size, equalTo(24))
9899
}
99100
}

0 commit comments

Comments
 (0)