Merge pull request #14 from 0pen-dash/adrian/history-persistance
db create a bit more readable
This commit is contained in:
commit
67be27ac60
1 changed files with 13 additions and 17 deletions
|
@ -39,25 +39,21 @@ class DashHistory @Inject constructor(
|
||||||
|
|
||||||
when {
|
when {
|
||||||
commandType == SET_BOLUS && bolusRecord == null ->
|
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 ->
|
commandType == SET_TEMPORARY_BASAL && tempBasalRecord == null ->
|
||||||
Single.error<String>(IllegalArgumentException("tempBasalRecord missing on SET_TEMPORARY_BASAL"))
|
return Single.error(IllegalArgumentException("tempBasalRecord missing on SET_TEMPORARY_BASAL"))
|
||||||
else -> null
|
}
|
||||||
}?.let { return it }
|
|
||||||
|
|
||||||
|
return dao.save(HistoryRecordEntity(
|
||||||
return dao.save(
|
id = id,
|
||||||
HistoryRecordEntity(
|
date = date,
|
||||||
id = id,
|
createdAt = currentTimeMillis(),
|
||||||
date = date,
|
commandType = commandType,
|
||||||
createdAt = currentTimeMillis(),
|
tempBasalRecord = tempBasalRecord,
|
||||||
commandType = commandType,
|
bolusRecord = bolusRecord,
|
||||||
tempBasalRecord = tempBasalRecord,
|
initialResult = initialResult,
|
||||||
bolusRecord = bolusRecord,
|
resolvedResult = resolveResult,
|
||||||
initialResult = initialResult,
|
resolvedAt = resolvedAt)
|
||||||
resolvedResult = resolveResult,
|
|
||||||
resolvedAt = resolvedAt,
|
|
||||||
)
|
|
||||||
).toSingle { id }
|
).toSingle { id }
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue