Merge pull request #14 from 0pen-dash/adrian/history-persistance

db create a bit more readable
This commit is contained in:
bartsopers 2021-02-28 18:28:08 +01:00 committed by GitHub
commit 67be27ac60
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -39,15 +39,12 @@ class DashHistory @Inject constructor(
when {
commandType == SET_BOLUS && bolusRecord == null ->
Single.error(IllegalArgumentException("bolusRecord missing on SET_BOLUS"))
return Single.error(IllegalArgumentException("bolusRecord missing on SET_BOLUS"))
commandType == SET_TEMPORARY_BASAL && tempBasalRecord == null ->
Single.error<String>(IllegalArgumentException("tempBasalRecord missing on SET_TEMPORARY_BASAL"))
else -> null
}?.let { return it }
return Single.error(IllegalArgumentException("tempBasalRecord missing on SET_TEMPORARY_BASAL"))
}
return dao.save(
HistoryRecordEntity(
return dao.save(HistoryRecordEntity(
id = id,
date = date,
createdAt = currentTimeMillis(),
@ -56,8 +53,7 @@ class DashHistory @Inject constructor(
bolusRecord = bolusRecord,
initialResult = initialResult,
resolvedResult = resolveResult,
resolvedAt = resolvedAt,
)
resolvedAt = resolvedAt)
).toSingle { id }
}