Fix loading bucketed data

This commit is contained in:
Milos Kozak 2023-01-08 17:18:23 +01:00
parent 86be6719e0
commit 4b6eab6aa4
3 changed files with 10 additions and 4 deletions

View file

@ -389,6 +389,10 @@ class IobCobCalculatorPlugin @Inject constructor(
// cancel waiting task to prevent sending multiple posts
scheduledHistoryPost?.cancel(false)
// prepare task for execution in 1 sec
scheduledEvent?.let {
// set reload bg data if was not set
if (!event.reloadBgData) event.reloadBgData = it.reloadBgData
}
scheduledEvent = event
scheduledHistoryPost = historyWorker.schedule(
{

View file

@ -315,9 +315,11 @@ class AutosensDataStoreObject : AutosensDataStore {
val previous = bData[i + 1]
val mSecDiff = current.timestamp - previous.timestamp
val adjusted = (mSecDiff - T.mins(5).msecs()) / 1000
aapsLogger.debug(LTag.AUTOSENS) { "Adjusting bucketed data time. Current: ${dateUtil.dateAndTimeAndSecondsString(current.timestamp)} to: ${dateUtil.dateAndTimeAndSecondsString(previous.timestamp + T.mins(
5
).msecs())} by $adjusted sec" }
aapsLogger.debug(LTag.AUTOSENS) {
"Adjusting bucketed data time. Current: ${dateUtil.dateAndTimeAndSecondsString(current.timestamp)} to: ${
dateUtil.dateAndTimeAndSecondsString(previous.timestamp + T.mins(5).msecs())
} by $adjusted sec"
}
if (abs(adjusted) > 90) {
// too big adjustment, fallback to non 5 min data
aapsLogger.debug(LTag.AUTOSENS, "Fallback to non 5 min data")

View file

@ -43,7 +43,7 @@ class PrepareBgDataWorker(
val toTime = data.overviewData.toTime
val fromTime = data.overviewData.fromTime
data.overviewData.maxBgValue = Double.MIN_VALUE
data.overviewData.bgReadingsArray = repository.compatGetBgReadingsDataFromTime(data.overviewData.fromTime, data.overviewData.toTime, false).blockingGet()
data.overviewData.bgReadingsArray = repository.compatGetBgReadingsDataFromTime(fromTime, toTime, false).blockingGet()
val bgListArray: MutableList<DataPointWithLabelInterface> = ArrayList()
for (bg in data.overviewData.bgReadingsArray) {
if (bg.timestamp < fromTime || bg.timestamp > toTime) continue