Fix workout sync to track end time instead of start time for last synced position

Changed getLastSampleTimestamp() for WORKOUTS to use workout EndTime instead of
StartTime. Previously, using StartTime caused the sync state to advance only to
the start of the last workout, resulting in that workout being re-synced on every
sync run and any new workouts started after it being missed until the next sync.
Now correctly advances to workout end time, ensuring proper incremental sync.
This commit is contained in:
Gideon Zenz
2026-01-04 13:54:25 +01:00
parent eb0b6fdd4f
commit 687b812ed4
@@ -672,11 +672,11 @@ class HealthConnectUtils {
val deviceEntity = DBHelper.getDevice(device, db.daoSession) ?: return null
return db.daoSession.baseActivitySummaryDao?.queryBuilder()
?.where(BaseActivitySummaryDao.Properties.DeviceId.eq(deviceEntity.id))
?.orderDesc(BaseActivitySummaryDao.Properties.StartTime)
?.orderDesc(BaseActivitySummaryDao.Properties.EndTime)
?.limit(1)
?.list()
?.firstOrNull()
?.startTime?.toInstant()
?.endTime?.toInstant()
}
else -> {
CompanionLogger.error("No suitable provider found or provider is null for getLastSampleTimestamp, dataType: {}, device: {}", dataType, device.name)