do not full_sync DeviceStatus
This commit is contained in:
parent
94cc26ffea
commit
6ad50d2979
1 changed files with 122 additions and 32 deletions
|
@ -90,7 +90,6 @@ class DataSyncSelectorImplementation @Inject constructor(
|
|||
sp.remove(R.string.key_ns_bolus_last_synced_id)
|
||||
sp.remove(R.string.key_ns_carbs_last_synced_id)
|
||||
sp.remove(R.string.key_ns_bolus_calculator_result_last_synced_id)
|
||||
sp.remove(R.string.key_ns_device_status_last_synced_id)
|
||||
sp.remove(R.string.key_ns_temporary_basal_last_synced_id)
|
||||
sp.remove(R.string.key_ns_extended_bolus_last_synced_id)
|
||||
sp.remove(R.string.key_ns_therapy_event_last_synced_id)
|
||||
|
@ -98,6 +97,9 @@ class DataSyncSelectorImplementation @Inject constructor(
|
|||
sp.remove(R.string.key_ns_effective_profile_switch_last_synced_id)
|
||||
sp.remove(R.string.key_ns_offline_event_last_synced_id)
|
||||
sp.remove(R.string.key_ns_profile_store_last_synced_timestamp)
|
||||
val lastDbIdWrapped = appRepository.getLastDeviceStatusIdWrapped().blockingGet()
|
||||
if (lastDbIdWrapped is ValueWrapper.Existing) sp.putLong(R.string.key_ns_device_status_last_synced_id, lastDbIdWrapped.value)
|
||||
else sp.remove(R.string.key_ns_device_status_last_synced_id)
|
||||
}
|
||||
|
||||
override fun confirmLastBolusIdIfGreater(lastSynced: Long) {
|
||||
|
@ -148,7 +150,13 @@ class DataSyncSelectorImplementation @Inject constructor(
|
|||
nsClientPlugin.nsClientService?.dbAdd("treatments", bolus.first.toJson(true, dateUtil), DataSyncSelector.PairBolus(bolus.first, bolus.second.id), "$startId/$lastDbId")
|
||||
// with nsId = update
|
||||
bolus.first.interfaceIDs.nightscoutId != null ->
|
||||
nsClientPlugin.nsClientService?.dbUpdate("treatments", bolus.first.interfaceIDs.nightscoutId, bolus.first.toJson(false, dateUtil), DataSyncSelector.PairBolus(bolus.first, bolus.second.id), "$startId/$lastDbId")
|
||||
nsClientPlugin.nsClientService?.dbUpdate(
|
||||
"treatments",
|
||||
bolus.first.interfaceIDs.nightscoutId,
|
||||
bolus.first.toJson(false, dateUtil),
|
||||
DataSyncSelector.PairBolus(bolus.first, bolus.second.id),
|
||||
"$startId/$lastDbId"
|
||||
)
|
||||
}
|
||||
return true
|
||||
}
|
||||
|
@ -200,7 +208,13 @@ class DataSyncSelectorImplementation @Inject constructor(
|
|||
nsClientPlugin.nsClientService?.dbAdd("treatments", carb.first.toJson(true, dateUtil), DataSyncSelector.PairCarbs(carb.first, carb.second.id), "$startId/$lastDbId")
|
||||
// with nsId = update
|
||||
carb.first.interfaceIDs.nightscoutId != null ->
|
||||
nsClientPlugin.nsClientService?.dbUpdate("treatments", carb.first.interfaceIDs.nightscoutId, carb.first.toJson(false, dateUtil), DataSyncSelector.PairCarbs(carb.first, carb.second.id), "$startId/$lastDbId")
|
||||
nsClientPlugin.nsClientService?.dbUpdate(
|
||||
"treatments",
|
||||
carb.first.interfaceIDs.nightscoutId,
|
||||
carb.first.toJson(false, dateUtil),
|
||||
DataSyncSelector.PairCarbs(carb.first, carb.second.id),
|
||||
"$startId/$lastDbId"
|
||||
)
|
||||
}
|
||||
return true
|
||||
}
|
||||
|
@ -249,11 +263,18 @@ class DataSyncSelectorImplementation @Inject constructor(
|
|||
}
|
||||
// without nsId = create new
|
||||
bolusCalculatorResult.first.interfaceIDs.nightscoutId == null ->
|
||||
nsClientPlugin.nsClientService?.dbAdd("treatments", bolusCalculatorResult.first.toJson(true, dateUtil), DataSyncSelector.PairBolusCalculatorResult(bolusCalculatorResult.first, bolusCalculatorResult.second.id), "$startId/$lastDbId")
|
||||
nsClientPlugin.nsClientService?.dbAdd(
|
||||
"treatments",
|
||||
bolusCalculatorResult.first.toJson(true, dateUtil),
|
||||
DataSyncSelector.PairBolusCalculatorResult(bolusCalculatorResult.first, bolusCalculatorResult.second.id),
|
||||
"$startId/$lastDbId"
|
||||
)
|
||||
// with nsId = update
|
||||
bolusCalculatorResult.first.interfaceIDs.nightscoutId != null ->
|
||||
nsClientPlugin.nsClientService?.dbUpdate("treatments", bolusCalculatorResult.first.interfaceIDs.nightscoutId, bolusCalculatorResult.first.toJson(false, dateUtil),
|
||||
DataSyncSelector.PairBolusCalculatorResult(bolusCalculatorResult.first, bolusCalculatorResult.second.id), "$startId/$lastDbId")
|
||||
nsClientPlugin.nsClientService?.dbUpdate(
|
||||
"treatments", bolusCalculatorResult.first.interfaceIDs.nightscoutId, bolusCalculatorResult.first.toJson(false, dateUtil),
|
||||
DataSyncSelector.PairBolusCalculatorResult(bolusCalculatorResult.first, bolusCalculatorResult.second.id), "$startId/$lastDbId"
|
||||
)
|
||||
}
|
||||
return true
|
||||
}
|
||||
|
@ -302,10 +323,21 @@ class DataSyncSelectorImplementation @Inject constructor(
|
|||
}
|
||||
// without nsId = create new
|
||||
tt.first.interfaceIDs.nightscoutId == null ->
|
||||
nsClientPlugin.nsClientService?.dbAdd("treatments", tt.first.toJson(true, profileFunction.getUnits(), dateUtil), DataSyncSelector.PairTemporaryTarget(tt.first, tt.second.id), "$startId/$lastDbId")
|
||||
nsClientPlugin.nsClientService?.dbAdd(
|
||||
"treatments",
|
||||
tt.first.toJson(true, profileFunction.getUnits(), dateUtil),
|
||||
DataSyncSelector.PairTemporaryTarget(tt.first, tt.second.id),
|
||||
"$startId/$lastDbId"
|
||||
)
|
||||
// existing with nsId = update
|
||||
tt.first.interfaceIDs.nightscoutId != null ->
|
||||
nsClientPlugin.nsClientService?.dbUpdate("treatments", tt.first.interfaceIDs.nightscoutId, tt.first.toJson(false, profileFunction.getUnits(), dateUtil), DataSyncSelector.PairTemporaryTarget(tt.first, tt.second.id), "$startId/$lastDbId")
|
||||
nsClientPlugin.nsClientService?.dbUpdate(
|
||||
"treatments",
|
||||
tt.first.interfaceIDs.nightscoutId,
|
||||
tt.first.toJson(false, profileFunction.getUnits(), dateUtil),
|
||||
DataSyncSelector.PairTemporaryTarget(tt.first, tt.second.id),
|
||||
"$startId/$lastDbId"
|
||||
)
|
||||
}
|
||||
return true
|
||||
}
|
||||
|
@ -357,7 +389,13 @@ class DataSyncSelectorImplementation @Inject constructor(
|
|||
nsClientPlugin.nsClientService?.dbAdd("food", food.first.toJson(true), DataSyncSelector.PairFood(food.first, food.second.id), "$startId/$lastDbId")
|
||||
// with nsId = update
|
||||
food.first.interfaceIDs.nightscoutId != null ->
|
||||
nsClientPlugin.nsClientService?.dbUpdate("food", food.first.interfaceIDs.nightscoutId, food.first.toJson(false), DataSyncSelector.PairFood(food.first, food.second.id), "$startId/$lastDbId")
|
||||
nsClientPlugin.nsClientService?.dbUpdate(
|
||||
"food",
|
||||
food.first.interfaceIDs.nightscoutId,
|
||||
food.first.toJson(false),
|
||||
DataSyncSelector.PairFood(food.first, food.second.id),
|
||||
"$startId/$lastDbId"
|
||||
)
|
||||
}
|
||||
return true
|
||||
}
|
||||
|
@ -410,7 +448,13 @@ class DataSyncSelectorImplementation @Inject constructor(
|
|||
nsClientPlugin.nsClientService?.dbAdd("entries", gv.first.toJson(true, dateUtil), DataSyncSelector.PairGlucoseValue(gv.first, gv.second.id), "$startId/$lastDbId")
|
||||
// with nsId = update
|
||||
gv.first.interfaceIDs.nightscoutId != null ->
|
||||
nsClientPlugin.nsClientService?.dbUpdate("entries", gv.first.interfaceIDs.nightscoutId, gv.first.toJson(false, dateUtil), DataSyncSelector.PairGlucoseValue(gv.first, gv.second.id), "$startId/$lastDbId")
|
||||
nsClientPlugin.nsClientService?.dbUpdate(
|
||||
"entries",
|
||||
gv.first.interfaceIDs.nightscoutId,
|
||||
gv.first.toJson(false, dateUtil),
|
||||
DataSyncSelector.PairGlucoseValue(gv.first, gv.second.id),
|
||||
"$startId/$lastDbId"
|
||||
)
|
||||
}
|
||||
return true
|
||||
} else {
|
||||
|
@ -467,7 +511,13 @@ class DataSyncSelectorImplementation @Inject constructor(
|
|||
nsClientPlugin.nsClientService?.dbAdd("treatments", te.first.toJson(true, dateUtil), DataSyncSelector.PairTherapyEvent(te.first, te.second.id), "$startId/$lastDbId")
|
||||
// nsId = update
|
||||
te.first.interfaceIDs.nightscoutId != null ->
|
||||
nsClientPlugin.nsClientService?.dbUpdate("treatments", te.first.interfaceIDs.nightscoutId, te.first.toJson(false, dateUtil), DataSyncSelector.PairTherapyEvent(te.first, te.second.id), "$startId/$lastDbId")
|
||||
nsClientPlugin.nsClientService?.dbUpdate(
|
||||
"treatments",
|
||||
te.first.interfaceIDs.nightscoutId,
|
||||
te.first.toJson(false, dateUtil),
|
||||
DataSyncSelector.PairTherapyEvent(te.first, te.second.id),
|
||||
"$startId/$lastDbId"
|
||||
)
|
||||
}
|
||||
return true
|
||||
}
|
||||
|
@ -561,10 +611,21 @@ class DataSyncSelectorImplementation @Inject constructor(
|
|||
}
|
||||
// without nsId = create new
|
||||
tb.first.interfaceIDs.nightscoutId == null ->
|
||||
nsClientPlugin.nsClientService?.dbAdd("treatments", tb.first.toJson(true, profile, dateUtil, useAbsolute), DataSyncSelector.PairTemporaryBasal(tb.first, tb.second.id), "$startId/$lastDbId")
|
||||
nsClientPlugin.nsClientService?.dbAdd(
|
||||
"treatments",
|
||||
tb.first.toJson(true, profile, dateUtil, useAbsolute),
|
||||
DataSyncSelector.PairTemporaryBasal(tb.first, tb.second.id),
|
||||
"$startId/$lastDbId"
|
||||
)
|
||||
// with nsId = update
|
||||
tb.first.interfaceIDs.nightscoutId != null ->
|
||||
nsClientPlugin.nsClientService?.dbUpdate("treatments", tb.first.interfaceIDs.nightscoutId, tb.first.toJson(false, profile, dateUtil, useAbsolute), DataSyncSelector.PairTemporaryBasal(tb.first, tb.second.id), "$startId/$lastDbId")
|
||||
nsClientPlugin.nsClientService?.dbUpdate(
|
||||
"treatments",
|
||||
tb.first.interfaceIDs.nightscoutId,
|
||||
tb.first.toJson(false, profile, dateUtil, useAbsolute),
|
||||
DataSyncSelector.PairTemporaryBasal(tb.first, tb.second.id),
|
||||
"$startId/$lastDbId"
|
||||
)
|
||||
}
|
||||
return true
|
||||
} else {
|
||||
|
@ -621,10 +682,21 @@ class DataSyncSelectorImplementation @Inject constructor(
|
|||
}
|
||||
// without nsId = create new
|
||||
eb.first.interfaceIDs.nightscoutId == null ->
|
||||
nsClientPlugin.nsClientService?.dbAdd("treatments", eb.first.toJson(true, profile, dateUtil, useAbsolute), DataSyncSelector.PairExtendedBolus(eb.first, eb.second.id), "$startId/$lastDbId")
|
||||
nsClientPlugin.nsClientService?.dbAdd(
|
||||
"treatments",
|
||||
eb.first.toJson(true, profile, dateUtil, useAbsolute),
|
||||
DataSyncSelector.PairExtendedBolus(eb.first, eb.second.id),
|
||||
"$startId/$lastDbId"
|
||||
)
|
||||
// with nsId = update
|
||||
eb.first.interfaceIDs.nightscoutId != null ->
|
||||
nsClientPlugin.nsClientService?.dbUpdate("treatments", eb.first.interfaceIDs.nightscoutId, eb.first.toJson(false, profile, dateUtil, useAbsolute), DataSyncSelector.PairExtendedBolus(eb.first, eb.second.id), "$startId/$lastDbId")
|
||||
nsClientPlugin.nsClientService?.dbUpdate(
|
||||
"treatments",
|
||||
eb.first.interfaceIDs.nightscoutId,
|
||||
eb.first.toJson(false, profile, dateUtil, useAbsolute),
|
||||
DataSyncSelector.PairExtendedBolus(eb.first, eb.second.id),
|
||||
"$startId/$lastDbId"
|
||||
)
|
||||
}
|
||||
return true
|
||||
} else {
|
||||
|
@ -680,7 +752,13 @@ class DataSyncSelectorImplementation @Inject constructor(
|
|||
nsClientPlugin.nsClientService?.dbAdd("treatments", ps.first.toJson(true, dateUtil), DataSyncSelector.PairProfileSwitch(ps.first, ps.second.id), "$startId/$lastDbId")
|
||||
// with nsId = update
|
||||
ps.first.interfaceIDs.nightscoutId != null ->
|
||||
nsClientPlugin.nsClientService?.dbUpdate("treatments", ps.first.interfaceIDs.nightscoutId, ps.first.toJson(false, dateUtil), DataSyncSelector.PairProfileSwitch(ps.first, ps.second.id), "$startId/$lastDbId")
|
||||
nsClientPlugin.nsClientService?.dbUpdate(
|
||||
"treatments",
|
||||
ps.first.interfaceIDs.nightscoutId,
|
||||
ps.first.toJson(false, dateUtil),
|
||||
DataSyncSelector.PairProfileSwitch(ps.first, ps.second.id),
|
||||
"$startId/$lastDbId"
|
||||
)
|
||||
}
|
||||
return true
|
||||
}
|
||||
|
@ -731,7 +809,13 @@ class DataSyncSelectorImplementation @Inject constructor(
|
|||
nsClientPlugin.nsClientService?.dbAdd("treatments", ps.first.toJson(true, dateUtil), DataSyncSelector.PairEffectiveProfileSwitch(ps.first, ps.second.id), "$startId/$lastDbId")
|
||||
// with nsId = update
|
||||
ps.first.interfaceIDs.nightscoutId != null ->
|
||||
nsClientPlugin.nsClientService?.dbUpdate("treatments", ps.first.interfaceIDs.nightscoutId, ps.first.toJson(false, dateUtil), DataSyncSelector.PairEffectiveProfileSwitch(ps.first, ps.second.id), "$startId/$lastDbId")
|
||||
nsClientPlugin.nsClientService?.dbUpdate(
|
||||
"treatments",
|
||||
ps.first.interfaceIDs.nightscoutId,
|
||||
ps.first.toJson(false, dateUtil),
|
||||
DataSyncSelector.PairEffectiveProfileSwitch(ps.first, ps.second.id),
|
||||
"$startId/$lastDbId"
|
||||
)
|
||||
}
|
||||
return true
|
||||
}
|
||||
|
@ -783,7 +867,13 @@ class DataSyncSelectorImplementation @Inject constructor(
|
|||
nsClientPlugin.nsClientService?.dbAdd("treatments", oe.first.toJson(true, dateUtil), DataSyncSelector.PairOfflineEvent(oe.first, oe.second.id), "$startId/$lastDbId")
|
||||
// existing with nsId = update
|
||||
oe.first.interfaceIDs.nightscoutId != null ->
|
||||
nsClientPlugin.nsClientService?.dbUpdate("treatments", oe.first.interfaceIDs.nightscoutId, oe.first.toJson(false, dateUtil), DataSyncSelector.PairOfflineEvent(oe.first, oe.second.id), "$startId/$lastDbId")
|
||||
nsClientPlugin.nsClientService?.dbUpdate(
|
||||
"treatments",
|
||||
oe.first.interfaceIDs.nightscoutId,
|
||||
oe.first.toJson(false, dateUtil),
|
||||
DataSyncSelector.PairOfflineEvent(oe.first, oe.second.id),
|
||||
"$startId/$lastDbId"
|
||||
)
|
||||
}
|
||||
return true
|
||||
}
|
||||
|
|
Loading…
Add table
Reference in a new issue