NSCv3: log upload
This commit is contained in:
parent
c25c9cedbf
commit
c1c46939ba
|
@ -20,7 +20,7 @@ class DataSyncSelectorImplementation @Inject constructor(
|
||||||
private val dateUtil: DateUtil,
|
private val dateUtil: DateUtil,
|
||||||
private val profileFunction: ProfileFunction,
|
private val profileFunction: ProfileFunction,
|
||||||
private val activePlugin: ActivePlugin,
|
private val activePlugin: ActivePlugin,
|
||||||
private val appRepository: AppRepository,
|
private val appRepository: AppRepository
|
||||||
) : DataSyncSelector {
|
) : DataSyncSelector {
|
||||||
|
|
||||||
class QueueCounter(
|
class QueueCounter(
|
||||||
|
|
|
@ -6,6 +6,9 @@ import info.nightscout.androidaps.annotations.OpenForTesting
|
||||||
import info.nightscout.core.utils.worker.LoggingWorker
|
import info.nightscout.core.utils.worker.LoggingWorker
|
||||||
import info.nightscout.interfaces.plugin.ActivePlugin
|
import info.nightscout.interfaces.plugin.ActivePlugin
|
||||||
import info.nightscout.interfaces.sync.DataSyncSelector
|
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
|
import javax.inject.Inject
|
||||||
|
|
||||||
@OpenForTesting
|
@OpenForTesting
|
||||||
|
@ -15,9 +18,15 @@ class DataSyncWorker(
|
||||||
|
|
||||||
@Inject lateinit var dataSyncSelector: DataSyncSelector
|
@Inject lateinit var dataSyncSelector: DataSyncSelector
|
||||||
@Inject lateinit var activePlugin: ActivePlugin
|
@Inject lateinit var activePlugin: ActivePlugin
|
||||||
|
@Inject lateinit var rxBus: RxBus
|
||||||
|
|
||||||
override fun doWorkAndLog(): Result {
|
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()
|
return Result.success()
|
||||||
}
|
}
|
||||||
}
|
}
|
|
@ -10,6 +10,7 @@ import info.nightscout.core.utils.fabric.FabricPrivacy
|
||||||
import info.nightscout.interfaces.plugin.ActivePlugin
|
import info.nightscout.interfaces.plugin.ActivePlugin
|
||||||
import info.nightscout.interfaces.sync.DataSyncSelector
|
import info.nightscout.interfaces.sync.DataSyncSelector
|
||||||
import info.nightscout.interfaces.sync.NsClient
|
import info.nightscout.interfaces.sync.NsClient
|
||||||
|
import info.nightscout.rx.bus.RxBus
|
||||||
import org.junit.jupiter.api.Assertions
|
import org.junit.jupiter.api.Assertions
|
||||||
import org.junit.jupiter.api.BeforeEach
|
import org.junit.jupiter.api.BeforeEach
|
||||||
import org.junit.jupiter.api.Test
|
import org.junit.jupiter.api.Test
|
||||||
|
@ -26,6 +27,7 @@ internal class DataSyncWorkerTest : TestBase() {
|
||||||
@Mock lateinit var context: ContextWithInjector
|
@Mock lateinit var context: ContextWithInjector
|
||||||
@Mock lateinit var activePlugin: ActivePlugin
|
@Mock lateinit var activePlugin: ActivePlugin
|
||||||
@Mock lateinit var nsClient: NsClient
|
@Mock lateinit var nsClient: NsClient
|
||||||
|
@Mock lateinit var rxBus: RxBus
|
||||||
|
|
||||||
private lateinit var sut: DataSyncWorker
|
private lateinit var sut: DataSyncWorker
|
||||||
|
|
||||||
|
@ -36,6 +38,7 @@ internal class DataSyncWorkerTest : TestBase() {
|
||||||
it.fabricPrivacy = fabricPrivacy
|
it.fabricPrivacy = fabricPrivacy
|
||||||
it.dataSyncSelector = dataSyncSelector
|
it.dataSyncSelector = dataSyncSelector
|
||||||
it.activePlugin = activePlugin
|
it.activePlugin = activePlugin
|
||||||
|
it.rxBus = rxBus
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue