Fix loading bucketed data
This commit is contained in:
parent
86be6719e0
commit
4b6eab6aa4
|
@ -389,6 +389,10 @@ class IobCobCalculatorPlugin @Inject constructor(
|
||||||
// cancel waiting task to prevent sending multiple posts
|
// cancel waiting task to prevent sending multiple posts
|
||||||
scheduledHistoryPost?.cancel(false)
|
scheduledHistoryPost?.cancel(false)
|
||||||
// prepare task for execution in 1 sec
|
// 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
|
scheduledEvent = event
|
||||||
scheduledHistoryPost = historyWorker.schedule(
|
scheduledHistoryPost = historyWorker.schedule(
|
||||||
{
|
{
|
||||||
|
|
|
@ -315,9 +315,11 @@ class AutosensDataStoreObject : AutosensDataStore {
|
||||||
val previous = bData[i + 1]
|
val previous = bData[i + 1]
|
||||||
val mSecDiff = current.timestamp - previous.timestamp
|
val mSecDiff = current.timestamp - previous.timestamp
|
||||||
val adjusted = (mSecDiff - T.mins(5).msecs()) / 1000
|
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(
|
aapsLogger.debug(LTag.AUTOSENS) {
|
||||||
5
|
"Adjusting bucketed data time. Current: ${dateUtil.dateAndTimeAndSecondsString(current.timestamp)} to: ${
|
||||||
).msecs())} by $adjusted sec" }
|
dateUtil.dateAndTimeAndSecondsString(previous.timestamp + T.mins(5).msecs())
|
||||||
|
} by $adjusted sec"
|
||||||
|
}
|
||||||
if (abs(adjusted) > 90) {
|
if (abs(adjusted) > 90) {
|
||||||
// too big adjustment, fallback to non 5 min data
|
// too big adjustment, fallback to non 5 min data
|
||||||
aapsLogger.debug(LTag.AUTOSENS, "Fallback to non 5 min data")
|
aapsLogger.debug(LTag.AUTOSENS, "Fallback to non 5 min data")
|
||||||
|
|
|
@ -43,7 +43,7 @@ class PrepareBgDataWorker(
|
||||||
val toTime = data.overviewData.toTime
|
val toTime = data.overviewData.toTime
|
||||||
val fromTime = data.overviewData.fromTime
|
val fromTime = data.overviewData.fromTime
|
||||||
data.overviewData.maxBgValue = Double.MIN_VALUE
|
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()
|
val bgListArray: MutableList<DataPointWithLabelInterface> = ArrayList()
|
||||||
for (bg in data.overviewData.bgReadingsArray) {
|
for (bg in data.overviewData.bgReadingsArray) {
|
||||||
if (bg.timestamp < fromTime || bg.timestamp > toTime) continue
|
if (bg.timestamp < fromTime || bg.timestamp > toTime) continue
|
||||||
|
|
Loading…
Reference in a new issue