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

Event warning in representation does not work (EXPOSUREAPP-14233,EXPOSUREAPP-14230 ) #5664

Merged
merged 10 commits into from
Oct 28, 2022
Original file line number Diff line number Diff line change
Expand Up @@ -80,10 +80,10 @@ class PresenceTracingTestViewModel @AssistedInject constructor(

val warningPackages = traceWarningRepository.allMetaData.first()
val overlaps = presenceTracingRiskRepository.allCheckInWarningOverlaps.first()
val lastResult = presenceTracingRiskRepository.allRiskLevelResults.first().singleOrNull()
val lastResult = presenceTracingRiskRepository.allRiskLevelResults.first().firstOrNull { it.wasSuccessfullyCalculated }

val infoText = when {
!lastResult!!.wasSuccessfullyCalculated -> "Last calculation failed"
lastResult?.wasSuccessfullyCalculated != true -> "Last calculation failed"
overlaps.isEmpty() -> "No matches found (${warningPackages.size} warning packages)."
overlaps.size > 100 -> "Output too large. ${overlaps.size} lines"
overlaps.isNotEmpty() -> overlaps.fold(StringBuilder()) { stringBuilder, checkInOverlap ->
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -164,7 +164,15 @@ internal fun CheckIn.calculateOverlap(
warning: TraceWarning.TraceTimeIntervalWarning,
traceWarningPackageId: String
): CheckInWarningOverlap? {
if (warning.locationIdHash.toOkioByteString() != traceLocationIdHash) return null
val warningLocationId = warning.locationIdHash.toOkioByteString()
if (warningLocationId != traceLocationIdHash) return run {
Timber.tag(TAG).d(
"warningLocationId=%s does NOT match traceLocationId=%s", warningLocationId, traceLocationIdHash
)
null
}

Timber.tag(TAG).d("warningLocationId matches traceLocationIdHash both are =%s", traceLocationIdHash)

val warningStartMillis = warning.startIntervalNumber.tenMinIntervalToMillis()
val warningEndMillis = (warning.startIntervalNumber + warning.period).tenMinIntervalToMillis()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -143,7 +143,7 @@ class TraceLocationWarnDurationFragment :
MaterialDatePicker
.Builder
.datePicker()
.setSelection(dateTime.toInstant(ZoneOffset.UTC).toEpochMilli())
.setSelection(dateTime.atZone(ZoneId.systemDefault()).toInstant().toEpochMilli())
.setCalendarConstraints(constraintsBuilder.build())
.build()
.apply {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ import kotlinx.coroutines.flow.MutableStateFlow
import java.time.Duration
import java.time.Instant
import java.time.LocalDateTime
import java.time.ZoneId
import java.time.ZoneOffset
import java.time.format.DateTimeFormatter
import java.time.format.FormatStyle
Expand Down Expand Up @@ -110,7 +111,7 @@ class TraceLocationWarnDurationViewModel @AssistedInject constructor(
}

fun getTraceLocationWarnDuration(traceLocation: TraceLocation): TraceLocationWarnDuration {
val startDate = localDateTime.toInstant(ZoneOffset.UTC)
val startDate = localDateTime.atZone(ZoneId.systemDefault()).toInstant()
return TraceLocationWarnDuration(
traceLocation = traceLocation,
startDate = startDate,
Expand Down