This commit is contained in:
Milos Kozak 2023-09-26 22:31:24 +02:00
parent 38d3c0cc31
commit c79b7cf477
7 changed files with 8 additions and 11 deletions

View file

@ -6,6 +6,7 @@ import app.aaps.database.entities.Bolus
import app.aaps.database.entities.BolusCalculatorResult import app.aaps.database.entities.BolusCalculatorResult
import app.aaps.database.entities.Carbs import app.aaps.database.entities.Carbs
import app.aaps.database.entities.EffectiveProfileSwitch import app.aaps.database.entities.EffectiveProfileSwitch
import app.aaps.database.entities.GlucoseValue
import app.aaps.database.entities.TemporaryTarget import app.aaps.database.entities.TemporaryTarget
import app.aaps.database.entities.UserEntry import app.aaps.database.entities.UserEntry
import dagger.android.HasAndroidInjector import dagger.android.HasAndroidInjector
@ -19,6 +20,7 @@ interface PersistenceLayer {
fun insertOrUpdateCarbs(carbs: Carbs, callback: Callback? = null, injector: HasAndroidInjector? = null) fun insertOrUpdateCarbs(carbs: Carbs, callback: Callback? = null, injector: HasAndroidInjector? = null)
fun insertOrUpdateBolus(bolus: Bolus) fun insertOrUpdateBolus(bolus: Bolus)
fun getLastGlucoseValue(): Single<ValueWrapper<GlucoseValue>>
fun getTemporaryTargetActiveAt(timestamp: Long): Single<ValueWrapper<TemporaryTarget>> fun getTemporaryTargetActiveAt(timestamp: Long): Single<ValueWrapper<TemporaryTarget>>
fun getUserEntryFilteredDataFromTime(timestamp: Long): Single<List<UserEntry>> fun getUserEntryFilteredDataFromTime(timestamp: Long): Single<List<UserEntry>>
fun getEffectiveProfileSwitchActiveAt(timestamp: Long): Single<ValueWrapper<EffectiveProfileSwitch>> fun getEffectiveProfileSwitchActiveAt(timestamp: Long): Single<ValueWrapper<EffectiveProfileSwitch>>

View file

@ -10,6 +10,7 @@ import app.aaps.database.entities.Bolus
import app.aaps.database.entities.BolusCalculatorResult import app.aaps.database.entities.BolusCalculatorResult
import app.aaps.database.entities.Carbs import app.aaps.database.entities.Carbs
import app.aaps.database.entities.EffectiveProfileSwitch import app.aaps.database.entities.EffectiveProfileSwitch
import app.aaps.database.entities.GlucoseValue
import app.aaps.database.entities.TemporaryTarget import app.aaps.database.entities.TemporaryTarget
import app.aaps.database.entities.UserEntry import app.aaps.database.entities.UserEntry
import app.aaps.database.impl.AppRepository import app.aaps.database.impl.AppRepository
@ -49,6 +50,8 @@ class PersistenceLayerImpl @Inject constructor(
) )
} }
override fun getLastGlucoseValue(): Single<ValueWrapper<GlucoseValue>> = repository.getLastGlucoseValueWrapped()
override fun insertOrUpdateCarbs(carbs: Carbs, callback: Callback?, injector: HasAndroidInjector?) { override fun insertOrUpdateCarbs(carbs: Carbs, callback: Callback?, injector: HasAndroidInjector?) {
disposable += repository.runTransactionForResult(InsertOrUpdateCarbsTransaction(carbs)) disposable += repository.runTransactionForResult(InsertOrUpdateCarbsTransaction(carbs))
.subscribe( .subscribe(

View file

@ -30,7 +30,6 @@ import app.aaps.core.nssdk.localmodel.devicestatus.NSDeviceStatus
import app.aaps.core.utils.JsonHelper.safeGetString import app.aaps.core.utils.JsonHelper.safeGetString
import app.aaps.core.utils.JsonHelper.safeGetStringAllowNull import app.aaps.core.utils.JsonHelper.safeGetStringAllowNull
import app.aaps.core.utils.receivers.DataWorkerStorage import app.aaps.core.utils.receivers.DataWorkerStorage
import app.aaps.database.impl.AppRepository
import app.aaps.plugins.sync.R import app.aaps.plugins.sync.R
import app.aaps.plugins.sync.nsShared.NSAlarmObject import app.aaps.plugins.sync.nsShared.NSAlarmObject
import app.aaps.plugins.sync.nsShared.NsIncomingDataProcessor import app.aaps.plugins.sync.nsShared.NsIncomingDataProcessor
@ -85,7 +84,6 @@ import javax.inject.Inject
@Inject lateinit var dateUtil: DateUtil @Inject lateinit var dateUtil: DateUtil
@Inject lateinit var dataWorkerStorage: DataWorkerStorage @Inject lateinit var dataWorkerStorage: DataWorkerStorage
@Inject lateinit var dataSyncSelectorV1: DataSyncSelectorV1 @Inject lateinit var dataSyncSelectorV1: DataSyncSelectorV1
@Inject lateinit var repository: AppRepository
@Inject lateinit var uiInteraction: UiInteraction @Inject lateinit var uiInteraction: UiInteraction
@Inject lateinit var nsIncomingDataProcessor: NsIncomingDataProcessor @Inject lateinit var nsIncomingDataProcessor: NsIncomingDataProcessor
@Inject lateinit var storeDataForDb: StoreDataForDb @Inject lateinit var storeDataForDb: StoreDataForDb

View file

@ -26,7 +26,6 @@ import app.aaps.core.interfaces.sync.DataSyncSelector.PairTherapyEvent
import app.aaps.core.main.utils.worker.LoggingWorker import app.aaps.core.main.utils.worker.LoggingWorker
import app.aaps.core.utils.notifyAll import app.aaps.core.utils.notifyAll
import app.aaps.core.utils.receivers.DataWorkerStorage import app.aaps.core.utils.receivers.DataWorkerStorage
import app.aaps.database.impl.AppRepository
import app.aaps.plugins.sync.R import app.aaps.plugins.sync.R
import app.aaps.plugins.sync.nsclient.acks.NSAddAck import app.aaps.plugins.sync.nsclient.acks.NSAddAck
import kotlinx.coroutines.Dispatchers import kotlinx.coroutines.Dispatchers
@ -38,7 +37,6 @@ class NSClientAddAckWorker(
) : LoggingWorker(context, params, Dispatchers.Default) { ) : LoggingWorker(context, params, Dispatchers.Default) {
@Inject lateinit var dataWorkerStorage: DataWorkerStorage @Inject lateinit var dataWorkerStorage: DataWorkerStorage
@Inject lateinit var repository: AppRepository
@Inject lateinit var rxBus: RxBus @Inject lateinit var rxBus: RxBus
@Inject lateinit var aapsSchedulers: AapsSchedulers @Inject lateinit var aapsSchedulers: AapsSchedulers
@Inject lateinit var sp: SP @Inject lateinit var sp: SP

View file

@ -25,7 +25,6 @@ import app.aaps.database.entities.ProfileSwitch
import app.aaps.database.entities.TemporaryBasal import app.aaps.database.entities.TemporaryBasal
import app.aaps.database.entities.TemporaryTarget import app.aaps.database.entities.TemporaryTarget
import app.aaps.database.entities.TherapyEvent import app.aaps.database.entities.TherapyEvent
import app.aaps.database.impl.AppRepository
import app.aaps.plugins.sync.R import app.aaps.plugins.sync.R
import app.aaps.plugins.sync.nsclient.extensions.extendedBolusFromJson import app.aaps.plugins.sync.nsclient.extensions.extendedBolusFromJson
import app.aaps.plugins.sync.nsclient.extensions.fromJson import app.aaps.plugins.sync.nsclient.extensions.fromJson
@ -43,7 +42,6 @@ class NSClientAddUpdateWorker(
@Inject lateinit var config: Config @Inject lateinit var config: Config
@Inject lateinit var sp: SP @Inject lateinit var sp: SP
@Inject lateinit var dateUtil: DateUtil @Inject lateinit var dateUtil: DateUtil
@Inject lateinit var repository: AppRepository
@Inject lateinit var activePlugin: ActivePlugin @Inject lateinit var activePlugin: ActivePlugin
@Inject lateinit var rxBus: RxBus @Inject lateinit var rxBus: RxBus
@Inject lateinit var storeDataForDb: StoreDataForDb @Inject lateinit var storeDataForDb: StoreDataForDb

View file

@ -21,7 +21,6 @@ import app.aaps.core.interfaces.sync.DataSyncSelector.PairTherapyEvent
import app.aaps.core.main.utils.worker.LoggingWorker import app.aaps.core.main.utils.worker.LoggingWorker
import app.aaps.core.utils.notifyAll import app.aaps.core.utils.notifyAll
import app.aaps.core.utils.receivers.DataWorkerStorage import app.aaps.core.utils.receivers.DataWorkerStorage
import app.aaps.database.impl.AppRepository
import app.aaps.plugins.sync.nsclient.acks.NSUpdateAck import app.aaps.plugins.sync.nsclient.acks.NSUpdateAck
import kotlinx.coroutines.Dispatchers import kotlinx.coroutines.Dispatchers
import javax.inject.Inject import javax.inject.Inject
@ -32,7 +31,6 @@ class NSClientUpdateRemoveAckWorker(
) : LoggingWorker(context, params, Dispatchers.Default) { ) : LoggingWorker(context, params, Dispatchers.Default) {
@Inject lateinit var dataWorkerStorage: DataWorkerStorage @Inject lateinit var dataWorkerStorage: DataWorkerStorage
@Inject lateinit var repository: AppRepository
@Inject lateinit var rxBus: RxBus @Inject lateinit var rxBus: RxBus
@Inject lateinit var aapsSchedulers: AapsSchedulers @Inject lateinit var aapsSchedulers: AapsSchedulers

View file

@ -14,6 +14,7 @@ import androidx.work.WorkManager
import app.aaps.annotations.OpenForTesting import app.aaps.annotations.OpenForTesting
import app.aaps.core.interfaces.configuration.Config import app.aaps.core.interfaces.configuration.Config
import app.aaps.core.interfaces.configuration.Constants import app.aaps.core.interfaces.configuration.Constants
import app.aaps.core.interfaces.db.PersistenceLayer
import app.aaps.core.interfaces.logging.AAPSLogger import app.aaps.core.interfaces.logging.AAPSLogger
import app.aaps.core.interfaces.logging.LTag import app.aaps.core.interfaces.logging.LTag
import app.aaps.core.interfaces.notifications.Notification import app.aaps.core.interfaces.notifications.Notification
@ -57,7 +58,6 @@ import app.aaps.core.nssdk.mapper.toNSTreatment
import app.aaps.core.nssdk.remotemodel.LastModified import app.aaps.core.nssdk.remotemodel.LastModified
import app.aaps.database.ValueWrapper import app.aaps.database.ValueWrapper
import app.aaps.database.entities.interfaces.TraceableDBEntry import app.aaps.database.entities.interfaces.TraceableDBEntry
import app.aaps.database.impl.AppRepository
import app.aaps.plugins.sync.R import app.aaps.plugins.sync.R
import app.aaps.plugins.sync.nsShared.NSAlarmObject import app.aaps.plugins.sync.nsShared.NSAlarmObject
import app.aaps.plugins.sync.nsShared.NSClientFragment import app.aaps.plugins.sync.nsShared.NSClientFragment
@ -122,7 +122,7 @@ class NSClientV3Plugin @Inject constructor(
private val dateUtil: DateUtil, private val dateUtil: DateUtil,
private val uiInteraction: UiInteraction, private val uiInteraction: UiInteraction,
private val dataSyncSelectorV3: DataSyncSelectorV3, private val dataSyncSelectorV3: DataSyncSelectorV3,
private val repository: AppRepository, private val persistenceLayer: PersistenceLayer,
private val nsDeviceStatusHandler: NSDeviceStatusHandler, private val nsDeviceStatusHandler: NSDeviceStatusHandler,
private val nsClientSource: NSClientSource, private val nsClientSource: NSClientSource,
private val nsIncomingDataProcessor: NsIncomingDataProcessor, private val nsIncomingDataProcessor: NsIncomingDataProcessor,
@ -260,7 +260,7 @@ class NSClientV3Plugin @Inject constructor(
runLoop = Runnable { runLoop = Runnable {
var refreshInterval = T.mins(5).msecs() var refreshInterval = T.mins(5).msecs()
if (nsClientSource.isEnabled()) if (nsClientSource.isEnabled())
repository.getLastGlucoseValueWrapped().blockingGet().let { persistenceLayer.getLastGlucoseValue().blockingGet().let {
// if last value is older than 5 min or there is no bg // if last value is older than 5 min or there is no bg
if (it is ValueWrapper.Existing) { if (it is ValueWrapper.Existing) {
if (it.value.timestamp < dateUtil.now() - T.mins(5).plus(T.secs(20)).msecs()) { if (it.value.timestamp < dateUtil.now() - T.mins(5).plus(T.secs(20)).msecs()) {