Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -247,9 +247,16 @@ class WhoopRecordingService : Service() {
stopRecording()
} catch (e: Exception) {
startupMode = null
Timber.e(e, "Historical sync failed")
cleanupFailedSession(reason = "historical sync failed", wasHistoricalSync = true)
whoopRuntimeCoordinator.setState(WhoopRuntimeState.ERROR)
if (hasHistoricalProgress()) {
Timber.w(e, "Historical sync ended after receiving data; treating as partial success")
updateNotification("WHOOP history received - finishing sync")
cleanupFailedSession(reason = "historical sync ended after receiving data", wasHistoricalSync = true)
whoopRuntimeCoordinator.setState(WhoopRuntimeState.IDLE)
} else {
Timber.e(e, "Historical sync failed")
cleanupFailedSession(reason = "historical sync failed", wasHistoricalSync = true)
whoopRuntimeCoordinator.setState(WhoopRuntimeState.ERROR)
}
stopSelf()
}
}
Expand Down Expand Up @@ -761,6 +768,13 @@ class WhoopRecordingService : Service() {
historicalSkippedByCutoff = 0
}

private fun hasHistoricalProgress(): Boolean =
historicalImuPersisted > 0 ||
historicalPpgPersisted > 0 ||
historicalHrPersisted > 0 ||
historicalEventPersisted > 0 ||
historicalSkippedByCutoff > 0

private fun logHistoricalSummary(sessionId: Long) {
Timber.i(
"WHOOP historical sync summary session=$sessionId cutoff=$syncCutoffSeconds " +
Expand Down
Loading