Skip to content

Commit

Permalink
Better TDD handling
Browse files Browse the repository at this point in the history
  • Loading branch information
MilosKozak committed Jan 29, 2025
1 parent 964921b commit afad1ac
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -18,13 +18,20 @@ class InsertOrUpdateCachedTotalDailyDoseTransaction(
if (current == null) {
database.totalDailyDoseDao.insertNewEntry(tdd)
result.inserted.add(tdd)
} else {
} else if (
current.basalAmount != tdd.basalAmount ||
current.bolusAmount != tdd.bolusAmount ||
current.totalAmount != tdd.totalAmount ||
current.carbs != tdd.carbs
){
current.basalAmount = tdd.basalAmount
current.bolusAmount = tdd.bolusAmount
current.totalAmount = tdd.totalAmount
current.carbs = tdd.carbs
database.totalDailyDoseDao.updateExistingEntry(current)
result.updated.add(current)
} else {
result.notUpdated.add(current)
}

return result
Expand All @@ -34,5 +41,6 @@ class InsertOrUpdateCachedTotalDailyDoseTransaction(

val inserted = mutableListOf<TotalDailyDose>()
val updated = mutableListOf<TotalDailyDose>()
val notUpdated = mutableListOf<TotalDailyDose>()
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -1723,6 +1723,10 @@ class PersistenceLayerImpl @Inject constructor(
aapsLogger.debug(LTag.DATABASE, "Updated TotalDailyDose ${dateUtil.dateString(it.timestamp)} $it")
transactionResult.updated.add(it.fromDb())
}
result.notUpdated.forEach {
aapsLogger.debug(LTag.DATABASE, "Not updated TotalDailyDose ${dateUtil.dateString(it.timestamp)} $it")
transactionResult.updated.add(it.fromDb())
}
transactionResult
}

Expand Down

0 comments on commit afad1ac

Please sign in to comment.