From c1c46939bad7b517aa7e346d04f5ccc296f0169f Mon Sep 17 00:00:00 2001 From: Milos Kozak Date: Thu, 5 Jan 2023 20:51:44 +0100 Subject: [PATCH] NSCv3: log upload --- .../sync/nsShared/DataSyncSelectorImplementation.kt | 2 +- .../plugins/sync/nsclientV3/workers/DataSyncWorker.kt | 11 ++++++++++- .../sync/nsclientV3/workers/DataSyncWorkerTest.kt | 3 +++ 3 files changed, 14 insertions(+), 2 deletions(-) diff --git a/plugins/sync/src/main/java/info/nightscout/plugins/sync/nsShared/DataSyncSelectorImplementation.kt b/plugins/sync/src/main/java/info/nightscout/plugins/sync/nsShared/DataSyncSelectorImplementation.kt index c06d083e53..a0ec25f72d 100644 --- a/plugins/sync/src/main/java/info/nightscout/plugins/sync/nsShared/DataSyncSelectorImplementation.kt +++ b/plugins/sync/src/main/java/info/nightscout/plugins/sync/nsShared/DataSyncSelectorImplementation.kt @@ -20,7 +20,7 @@ class DataSyncSelectorImplementation @Inject constructor( private val dateUtil: DateUtil, private val profileFunction: ProfileFunction, private val activePlugin: ActivePlugin, - private val appRepository: AppRepository, + private val appRepository: AppRepository ) : DataSyncSelector { class QueueCounter( diff --git a/plugins/sync/src/main/java/info/nightscout/plugins/sync/nsclientV3/workers/DataSyncWorker.kt b/plugins/sync/src/main/java/info/nightscout/plugins/sync/nsclientV3/workers/DataSyncWorker.kt index b81a7b4055..4015c60ab8 100644 --- a/plugins/sync/src/main/java/info/nightscout/plugins/sync/nsclientV3/workers/DataSyncWorker.kt +++ b/plugins/sync/src/main/java/info/nightscout/plugins/sync/nsclientV3/workers/DataSyncWorker.kt @@ -6,6 +6,9 @@ import info.nightscout.androidaps.annotations.OpenForTesting import info.nightscout.core.utils.worker.LoggingWorker import info.nightscout.interfaces.plugin.ActivePlugin import info.nightscout.interfaces.sync.DataSyncSelector +import info.nightscout.plugins.sync.nsShared.events.EventNSClientUpdateGUI +import info.nightscout.rx.bus.RxBus +import info.nightscout.rx.events.EventNSClientNewLog import javax.inject.Inject @OpenForTesting @@ -15,9 +18,15 @@ class DataSyncWorker( @Inject lateinit var dataSyncSelector: DataSyncSelector @Inject lateinit var activePlugin: ActivePlugin + @Inject lateinit var rxBus: RxBus override fun doWorkAndLog(): Result { - if (activePlugin.activeNsClient?.hasWritePermission == true) dataSyncSelector.doUpload() + if (activePlugin.activeNsClient?.hasWritePermission == true) { + rxBus.send(EventNSClientNewLog("UPL", "Start")) + dataSyncSelector.doUpload() + rxBus.send(EventNSClientNewLog("UPL", "End")) + } + rxBus.send(EventNSClientUpdateGUI()) return Result.success() } } \ No newline at end of file diff --git a/plugins/sync/src/test/java/info/nightscout/plugins/sync/nsclientV3/workers/DataSyncWorkerTest.kt b/plugins/sync/src/test/java/info/nightscout/plugins/sync/nsclientV3/workers/DataSyncWorkerTest.kt index 059a83566c..8f509275b8 100644 --- a/plugins/sync/src/test/java/info/nightscout/plugins/sync/nsclientV3/workers/DataSyncWorkerTest.kt +++ b/plugins/sync/src/test/java/info/nightscout/plugins/sync/nsclientV3/workers/DataSyncWorkerTest.kt @@ -10,6 +10,7 @@ import info.nightscout.core.utils.fabric.FabricPrivacy import info.nightscout.interfaces.plugin.ActivePlugin import info.nightscout.interfaces.sync.DataSyncSelector import info.nightscout.interfaces.sync.NsClient +import info.nightscout.rx.bus.RxBus import org.junit.jupiter.api.Assertions import org.junit.jupiter.api.BeforeEach import org.junit.jupiter.api.Test @@ -26,6 +27,7 @@ internal class DataSyncWorkerTest : TestBase() { @Mock lateinit var context: ContextWithInjector @Mock lateinit var activePlugin: ActivePlugin @Mock lateinit var nsClient: NsClient + @Mock lateinit var rxBus: RxBus private lateinit var sut: DataSyncWorker @@ -36,6 +38,7 @@ internal class DataSyncWorkerTest : TestBase() { it.fabricPrivacy = fabricPrivacy it.dataSyncSelector = dataSyncSelector it.activePlugin = activePlugin + it.rxBus = rxBus } } }