Skip to content

Commit

Permalink
Merge pull request #14 from 0pen-dash/adrian/history-persistance
Browse files Browse the repository at this point in the history
db create a bit more readable
  • Loading branch information
bartsopers committed Feb 28, 2021
2 parents 42279e1 + 76756fa commit 67be27a
Showing 1 changed file with 13 additions and 17 deletions.
Expand Up @@ -39,25 +39,21 @@ 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(
id = id,
date = date,
createdAt = currentTimeMillis(),
commandType = commandType,
tempBasalRecord = tempBasalRecord,
bolusRecord = bolusRecord,
initialResult = initialResult,
resolvedResult = resolveResult,
resolvedAt = resolvedAt,
)
return dao.save(HistoryRecordEntity(
id = id,
date = date,
createdAt = currentTimeMillis(),
commandType = commandType,
tempBasalRecord = tempBasalRecord,
bolusRecord = bolusRecord,
initialResult = initialResult,
resolvedResult = resolveResult,
resolvedAt = resolvedAt)
).toSingle { id }
}

Expand Down

0 comments on commit 67be27a

Please sign in to comment.