Skip to content
This repository has been archived by the owner on Jun 20, 2023. It is now read-only.

Commit

Permalink
Merge branch 'fix/3152-country-list-bug' of https://github.com/corona…
Browse files Browse the repository at this point in the history
…-warn-app/cwa-app-android into fix/3152-country-list-bug
  • Loading branch information
Oliver-Zimmerman committed Oct 12, 2020
2 parents 4fc9133 + f443551 commit e4c7cd2
Show file tree
Hide file tree
Showing 4 changed files with 240 additions and 254 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -92,6 +92,7 @@ class KeyFileDownloader @Inject constructor(
Timber.tag(TAG).w("Missing keyfile for : %s", keyInfo)
null
} else {
Timber.tag(TAG).v("Providing available key: %s", keyInfo)
path
}
}
Expand Down Expand Up @@ -171,11 +172,21 @@ class KeyFileDownloader @Inject constructor(
availableCountries: List<LocationCode>,
itemLimit: Int
): List<CountryHours> {

val availableHours = availableCountries.flatMap { location ->
var remainingItems = itemLimit
// Descending because we go backwards newest -> oldest
keyServer.getDayIndex(location).sortedDescending().mapNotNull { day ->
val indexWithToday = keyServer.getDayIndex(location).let {
val lastDayInIndex = it.maxOrNull()
Timber.tag(TAG).v("Last day in index: %s", lastDayInIndex)
if (lastDayInIndex != null) {
it.plus(lastDayInIndex.plusDays(1))
} else {
it
}
}
Timber.tag(TAG).v("Day index with (fake) today entry: %s", indexWithToday)

indexWithToday.sortedDescending().mapNotNull { day ->
// Limit reached, return null (filtered out) instead of new CountryHours object
if (remainingItems <= 0) return@mapNotNull null

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -110,6 +110,6 @@ class DiagnosisKeyServer @Inject constructor(
companion object {
private val TAG = DiagnosisKeyServer::class.java.simpleName
private val DAY_FORMATTER = DateTimeFormat.forPattern("yyyy-MM-dd")
private val HOUR_FORMATTER = DateTimeFormat.forPattern("HH")
private val HOUR_FORMATTER = DateTimeFormat.forPattern("H")
}
}

0 comments on commit e4c7cd2

Please sign in to comment.