cleanup
This commit is contained in:
parent
394883165d
commit
49f29f348d
12 changed files with 24 additions and 141 deletions
|
@ -65,7 +65,7 @@ import kotlin.math.roundToInt
|
|||
fun <T : Any> runTransactionForResult(transaction: Transaction<T>): Single<T> {
|
||||
val changes = mutableListOf<DBEntry>()
|
||||
return Single.fromCallable {
|
||||
database.runInTransaction(Callable<T> {
|
||||
database.runInTransaction(Callable {
|
||||
transaction.database = DelegatedAppDatabase(changes, database)
|
||||
transaction.run()
|
||||
})
|
||||
|
@ -85,7 +85,7 @@ import kotlin.math.roundToInt
|
|||
removed.add(Pair("ExtendedBolus", database.extendedBolusDao.deleteOlderThan(than)))
|
||||
removed.add(Pair("Bolus", database.bolusDao.deleteOlderThan(than)))
|
||||
removed.add(Pair("MultiWaveBolus", database.multiwaveBolusLinkDao.deleteOlderThan(than)))
|
||||
//removed.add(Pair("TotalDailyDose", database.totalDailyDoseDao.deleteOlderThan(than)))
|
||||
// keep TDD removed.add(Pair("TotalDailyDose", database.totalDailyDoseDao.deleteOlderThan(than)))
|
||||
removed.add(Pair("Carbs", database.carbsDao.deleteOlderThan(than)))
|
||||
removed.add(Pair("TemporaryTarget", database.temporaryTargetDao.deleteOlderThan(than)))
|
||||
removed.add(Pair("ApsResultLink", database.apsResultLinkDao.deleteOlderThan(than)))
|
||||
|
@ -95,10 +95,10 @@ import kotlin.math.roundToInt
|
|||
removed.add(Pair("EffectiveProfileSwitch", database.effectiveProfileSwitchDao.deleteOlderThan(than)))
|
||||
removed.add(Pair("ProfileSwitch", database.profileSwitchDao.deleteOlderThan(than)))
|
||||
removed.add(Pair("ApsResult", database.apsResultDao.deleteOlderThan(than)))
|
||||
//database.versionChangeDao.deleteOlderThan(than)
|
||||
// keep version history database.versionChangeDao.deleteOlderThan(than)
|
||||
removed.add(Pair("UserEntry", database.userEntryDao.deleteOlderThan(than)))
|
||||
removed.add(Pair("PreferenceChange", database.preferenceChangeDao.deleteOlderThan(than)))
|
||||
//database.foodDao.deleteOlderThan(than)
|
||||
// keep foods database.foodDao.deleteOlderThan(than)
|
||||
removed.add(Pair("DeviceStatus", database.deviceStatusDao.deleteOlderThan(than)))
|
||||
removed.add(Pair("OfflineEvent", database.offlineEventDao.deleteOlderThan(than)))
|
||||
removed.add(Pair("HeartRate", database.heartRateDao.deleteOlderThan(than)))
|
||||
|
@ -110,7 +110,7 @@ import kotlin.math.roundToInt
|
|||
removed.add(Pair("Bolus", database.bolusDao.deleteTrackedChanges()))
|
||||
removed.add(Pair("ExtendedBolus", database.extendedBolusDao.deleteTrackedChanges()))
|
||||
removed.add(Pair("MultiWaveBolus", database.multiwaveBolusLinkDao.deleteTrackedChanges()))
|
||||
//removed.add(Pair("TotalDailyDose", database.totalDailyDoseDao.deleteTrackedChanges()))
|
||||
// keep TDD removed.add(Pair("TotalDailyDose", database.totalDailyDoseDao.deleteTrackedChanges()))
|
||||
removed.add(Pair("Carbs", database.carbsDao.deleteTrackedChanges()))
|
||||
removed.add(Pair("TemporaryTarget", database.temporaryTargetDao.deleteTrackedChanges()))
|
||||
removed.add(Pair("ApsResultLink", database.apsResultLinkDao.deleteTrackedChanges()))
|
||||
|
@ -118,7 +118,7 @@ import kotlin.math.roundToInt
|
|||
removed.add(Pair("EffectiveProfileSwitch", database.effectiveProfileSwitchDao.deleteTrackedChanges()))
|
||||
removed.add(Pair("ProfileSwitch", database.profileSwitchDao.deleteTrackedChanges()))
|
||||
removed.add(Pair("ApsResult", database.apsResultDao.deleteTrackedChanges()))
|
||||
//database.foodDao.deleteHistory()
|
||||
// keep food database.foodDao.deleteHistory()
|
||||
removed.add(Pair("OfflineEvent", database.offlineEventDao.deleteTrackedChanges()))
|
||||
removed.add(Pair("HeartRate", database.heartRateDao.deleteTrackedChanges()))
|
||||
}
|
||||
|
@ -148,6 +148,7 @@ import kotlin.math.roundToInt
|
|||
fun findBgReadingByNSId(nsId: String): GlucoseValue? =
|
||||
database.glucoseValueDao.findByNSId(nsId)
|
||||
|
||||
@Suppress("unused")
|
||||
fun getModifiedBgReadingsDataFromId(lastId: Long): Single<List<GlucoseValue>> =
|
||||
database.glucoseValueDao.getModifiedFrom(lastId)
|
||||
.subscribeOn(Schedulers.io())
|
||||
|
@ -179,14 +180,6 @@ import kotlin.math.roundToInt
|
|||
}
|
||||
}
|
||||
|
||||
fun getBgReadingsCorrespondingLastHistoryRecord(lastId: Long): GlucoseValue? =
|
||||
database.glucoseValueDao.getLastHistoryRecord(lastId)
|
||||
|
||||
@Suppress("unused") // debug purpose only
|
||||
fun getAllBgReadingsStartingFrom(lastId: Long): Single<List<GlucoseValue>> =
|
||||
database.glucoseValueDao.getAllStartingFrom(lastId)
|
||||
.subscribeOn(Schedulers.io())
|
||||
|
||||
// TEMP TARGETS
|
||||
fun findTemporaryTargetByNSId(nsId: String): TemporaryTarget? =
|
||||
database.temporaryTargetDao.findByNSId(nsId)
|
||||
|
@ -210,10 +203,6 @@ import kotlin.math.roundToInt
|
|||
}
|
||||
}
|
||||
|
||||
fun compatGetTemporaryTargetData(): Single<List<TemporaryTarget>> =
|
||||
database.temporaryTargetDao.getTemporaryTargetData()
|
||||
.subscribeOn(Schedulers.io())
|
||||
|
||||
fun getTemporaryTargetDataFromTime(timestamp: Long, ascending: Boolean): Single<List<TemporaryTarget>> =
|
||||
database.temporaryTargetDao.getTemporaryTargetDataFromTime(timestamp)
|
||||
.map { if (!ascending) it.reversed() else it }
|
||||
|
@ -224,6 +213,7 @@ import kotlin.math.roundToInt
|
|||
.map { if (!ascending) it.reversed() else it }
|
||||
.subscribeOn(Schedulers.io())
|
||||
|
||||
@Suppress("unused")
|
||||
fun getModifiedTemporaryTargetsDataFromId(lastId: Long): Single<List<TemporaryTarget>> =
|
||||
database.temporaryTargetDao.getModifiedFrom(lastId)
|
||||
.subscribeOn(Schedulers.io())
|
||||
|
@ -240,10 +230,6 @@ import kotlin.math.roundToInt
|
|||
database.temporaryTargetDao.getLastId()
|
||||
|
||||
// USER ENTRY
|
||||
fun getAllUserEntries(): Single<List<UserEntry>> =
|
||||
database.userEntryDao.getAll()
|
||||
.subscribeOn(Schedulers.io())
|
||||
|
||||
fun getUserEntryDataFromTime(timestamp: Long): Single<List<UserEntry>> =
|
||||
database.userEntryDao.getUserEntryDataFromTime(timestamp)
|
||||
.subscribeOn(Schedulers.io())
|
||||
|
@ -274,6 +260,7 @@ import kotlin.math.roundToInt
|
|||
}
|
||||
}
|
||||
|
||||
@Suppress("unused")
|
||||
fun getModifiedProfileSwitchDataFromId(lastId: Long): Single<List<ProfileSwitch>> =
|
||||
database.profileSwitchDao.getModifiedFrom(lastId)
|
||||
.subscribeOn(Schedulers.io())
|
||||
|
@ -288,8 +275,7 @@ import kotlin.math.roundToInt
|
|||
if (tps != null && ps != null)
|
||||
return if (ps.timestamp > tps.timestamp) ps else tps
|
||||
if (ps == null) return tps
|
||||
if (tps == null) return ps
|
||||
return null
|
||||
return ps // if (tps == null)
|
||||
}
|
||||
|
||||
fun getPermanentProfileSwitch(timestamp: Long): ProfileSwitch? =
|
||||
|
@ -340,6 +326,7 @@ import kotlin.math.roundToInt
|
|||
}
|
||||
}
|
||||
|
||||
@Suppress("unused")
|
||||
fun getModifiedEffectiveProfileSwitchDataFromId(lastId: Long): Single<List<EffectiveProfileSwitch>> =
|
||||
database.effectiveProfileSwitchDao.getModifiedFrom(lastId)
|
||||
.subscribeOn(Schedulers.io())
|
||||
|
@ -400,6 +387,7 @@ import kotlin.math.roundToInt
|
|||
}
|
||||
}
|
||||
|
||||
@Suppress("unused")
|
||||
fun getModifiedTherapyEventDataFromId(lastId: Long): Single<List<TherapyEvent>> =
|
||||
database.therapyEventDao.getModifiedFrom(lastId)
|
||||
.subscribeOn(Schedulers.io())
|
||||
|
@ -430,14 +418,6 @@ import kotlin.math.roundToInt
|
|||
database.therapyEventDao.getLastTherapyRecord(type, System.currentTimeMillis()).toWrappedSingle()
|
||||
.subscribeOn(Schedulers.io())
|
||||
|
||||
fun getTherapyEventByTimestamp(type: TherapyEvent.Type, timestamp: Long): TherapyEvent? =
|
||||
database.therapyEventDao.findByTimestamp(type, timestamp)
|
||||
|
||||
fun compatGetTherapyEventDataFromTime(timestamp: Long, ascending: Boolean): Single<List<TherapyEvent>> =
|
||||
database.therapyEventDao.compatGetTherapyEventDataFromTime(timestamp)
|
||||
.map { if (!ascending) it.reversed() else it }
|
||||
.subscribeOn(Schedulers.io())
|
||||
|
||||
fun compatGetTherapyEventDataFromToTime(from: Long, to: Long): Single<List<TherapyEvent>> =
|
||||
database.therapyEventDao.compatGetTherapyEventDataFromToTime(from, to)
|
||||
.subscribeOn(Schedulers.io())
|
||||
|
@ -446,9 +426,6 @@ import kotlin.math.roundToInt
|
|||
database.therapyEventDao.getLastId()
|
||||
|
||||
// FOOD
|
||||
fun findFoodByNSId(nsId: String): Food? =
|
||||
database.foodDao.findByNSId(nsId)
|
||||
|
||||
/*
|
||||
* returns a Pair of the next entity to sync and the ID of the "update".
|
||||
* The update id might either be the entry id itself if it is a new entry - or the id
|
||||
|
@ -468,6 +445,7 @@ import kotlin.math.roundToInt
|
|||
}
|
||||
}
|
||||
|
||||
@Suppress("unused")
|
||||
fun getModifiedFoodDataFromId(lastId: Long): Single<List<Food>> =
|
||||
database.foodDao.getModifiedFrom(lastId)
|
||||
.subscribeOn(Schedulers.io())
|
||||
|
@ -476,6 +454,7 @@ import kotlin.math.roundToInt
|
|||
database.foodDao.getFoodData()
|
||||
.subscribeOn(Schedulers.io())
|
||||
|
||||
@Suppress("unused")
|
||||
fun deleteAllFoods() =
|
||||
database.foodDao.deleteAllEntries()
|
||||
|
||||
|
@ -505,6 +484,7 @@ import kotlin.math.roundToInt
|
|||
}
|
||||
}
|
||||
|
||||
@Suppress("unused")
|
||||
fun getModifiedBolusesDataFromId(lastId: Long): Single<List<Bolus>> =
|
||||
database.bolusDao.getModifiedFrom(lastId)
|
||||
.subscribeOn(Schedulers.io())
|
||||
|
@ -540,11 +520,6 @@ import kotlin.math.roundToInt
|
|||
.map { if (!ascending) it.reversed() else it }
|
||||
.subscribeOn(Schedulers.io())
|
||||
|
||||
fun getBolusesIncludingInvalidFromTimeToTime(from: Long, to: Long, ascending: Boolean): Single<List<Bolus>> =
|
||||
database.bolusDao.getBolusesIncludingInvalidFromTimeToTime(from, to)
|
||||
.map { if (!ascending) it.reversed() else it }
|
||||
.subscribeOn(Schedulers.io())
|
||||
|
||||
fun deleteAllBoluses() =
|
||||
database.bolusDao.deleteAllEntries()
|
||||
|
||||
|
@ -570,9 +545,7 @@ import kotlin.math.roundToInt
|
|||
}
|
||||
|
||||
private fun Single<List<Carbs>>.expand() = this.map { it.map(::expandCarbs).flatten() }
|
||||
private fun Single<List<Carbs>>.filterOutExtended() = this.map { it.filter { c -> c.duration == 0L } }
|
||||
private fun Single<List<Carbs>>.fromTo(from: Long, to: Long) = this.map { it.filter { c -> c.timestamp in from..to } }
|
||||
private infix fun Single<List<Carbs>>.until(to: Long) = this.map { it.filter { c -> c.timestamp <= to } }
|
||||
private fun Single<List<Carbs>>.from(start: Long) = this.map { it.filter { c -> c.timestamp >= start } }
|
||||
private fun Single<List<Carbs>>.sort() = this.map { it.sortedBy { c -> c.timestamp } }
|
||||
|
||||
|
@ -595,13 +568,11 @@ import kotlin.math.roundToInt
|
|||
}
|
||||
}
|
||||
|
||||
@Suppress("unused")
|
||||
fun getModifiedCarbsDataFromId(lastId: Long): Single<List<Carbs>> =
|
||||
database.carbsDao.getModifiedFrom(lastId)
|
||||
.subscribeOn(Schedulers.io())
|
||||
|
||||
fun getCarbsByTimestamp(timestamp: Long): Carbs? =
|
||||
database.carbsDao.findByTimestamp(timestamp)
|
||||
|
||||
fun getLastCarbsRecord(): Carbs? =
|
||||
database.carbsDao.getLastCarbsRecord()
|
||||
|
||||
|
@ -630,11 +601,6 @@ import kotlin.math.roundToInt
|
|||
.map { if (!ascending) it.reversed() else it }
|
||||
.subscribeOn(Schedulers.io())
|
||||
|
||||
fun getCarbsDataFromTimeToTime(from: Long, to: Long, ascending: Boolean): Single<List<Carbs>> =
|
||||
database.carbsDao.getCarbsFromTimeToTime(from, to)
|
||||
.map { if (!ascending) it.reversed() else it }
|
||||
.subscribeOn(Schedulers.io())
|
||||
|
||||
fun getCarbsDataFromTimeToTimeExpanded(from: Long, to: Long, ascending: Boolean): Single<List<Carbs>> =
|
||||
database.carbsDao.getCarbsFromTimeToTimeExpandable(from, to)
|
||||
.expand()
|
||||
|
@ -648,21 +614,6 @@ import kotlin.math.roundToInt
|
|||
.map { if (!ascending) it.reversed() else it }
|
||||
.subscribeOn(Schedulers.io())
|
||||
|
||||
fun getCarbsIncludingInvalidFromTimeExpanded(timestamp: Long, ascending: Boolean): Single<List<Carbs>> =
|
||||
database.carbsDao.getCarbsIncludingInvalidFromTimeExpandable(timestamp)
|
||||
.expand()
|
||||
.from(timestamp)
|
||||
.map { if (!ascending) it.reversed() else it }
|
||||
.subscribeOn(Schedulers.io())
|
||||
|
||||
fun getCarbsIncludingInvalidFromTimeToTimeExpanded(from: Long, to: Long, ascending: Boolean): Single<List<Carbs>> =
|
||||
database.carbsDao.getCarbsIncludingInvalidFromTimeToTimeExpandable(from, to)
|
||||
.expand()
|
||||
.fromTo(from, to)
|
||||
.sort()
|
||||
.map { if (!ascending) it.reversed() else it }
|
||||
.subscribeOn(Schedulers.io())
|
||||
|
||||
fun deleteAllCarbs() =
|
||||
database.carbsDao.deleteAllEntries()
|
||||
|
||||
|
@ -692,6 +643,7 @@ import kotlin.math.roundToInt
|
|||
}
|
||||
}
|
||||
|
||||
@Suppress("unused")
|
||||
fun getModifiedBolusCalculatorResultsDataFromId(lastId: Long): Single<List<BolusCalculatorResult>> =
|
||||
database.bolusCalculatorResultDao.getModifiedFrom(lastId)
|
||||
.subscribeOn(Schedulers.io())
|
||||
|
@ -757,14 +709,11 @@ import kotlin.math.roundToInt
|
|||
}
|
||||
}
|
||||
|
||||
@Suppress("unused")
|
||||
fun getModifiedTemporaryBasalDataFromId(lastId: Long): Single<List<TemporaryBasal>> =
|
||||
database.temporaryBasalDao.getModifiedFrom(lastId)
|
||||
.subscribeOn(Schedulers.io())
|
||||
|
||||
fun getTemporaryBasalsData(): Single<List<TemporaryBasal>> =
|
||||
database.temporaryBasalDao.getTemporaryBasalData()
|
||||
.subscribeOn(Schedulers.io())
|
||||
|
||||
fun getTemporaryBasalActiveAt(timestamp: Long): Single<ValueWrapper<TemporaryBasal>> =
|
||||
database.temporaryBasalDao.getTemporaryBasalActiveAt(timestamp)
|
||||
.subscribeOn(Schedulers.io())
|
||||
|
@ -789,11 +738,6 @@ import kotlin.math.roundToInt
|
|||
.map { if (!ascending) it.reversed() else it }
|
||||
.subscribeOn(Schedulers.io())
|
||||
|
||||
fun getTemporaryBasalsDataIncludingInvalidFromTimeToTime(from: Long, to: Long, ascending: Boolean): Single<List<TemporaryBasal>> =
|
||||
database.temporaryBasalDao.getTemporaryBasalDataIncludingInvalidFromTimeToTime(from, to)
|
||||
.map { if (!ascending) it.reversed() else it }
|
||||
.subscribeOn(Schedulers.io())
|
||||
|
||||
fun getOldestTemporaryBasalRecord(): TemporaryBasal? =
|
||||
database.temporaryBasalDao.getOldestRecord()
|
||||
|
||||
|
@ -824,6 +768,7 @@ import kotlin.math.roundToInt
|
|||
}
|
||||
}
|
||||
|
||||
@Suppress("unused")
|
||||
fun getModifiedExtendedBolusDataFromId(lastId: Long): Single<List<ExtendedBolus>> =
|
||||
database.extendedBolusDao.getModifiedFrom(lastId)
|
||||
.subscribeOn(Schedulers.io())
|
||||
|
@ -848,11 +793,6 @@ import kotlin.math.roundToInt
|
|||
.map { if (!ascending) it.reversed() else it }
|
||||
.subscribeOn(Schedulers.io())
|
||||
|
||||
fun getExtendedBolusDataIncludingInvalidFromTimeToTime(start: Long, end: Long, ascending: Boolean): Single<List<ExtendedBolus>> =
|
||||
database.extendedBolusDao.getExtendedBolusDataIncludingInvalidFromTimeToTime(start, end)
|
||||
.map { if (!ascending) it.reversed() else it }
|
||||
.subscribeOn(Schedulers.io())
|
||||
|
||||
fun getOldestExtendedBolusRecord(): ExtendedBolus? =
|
||||
database.extendedBolusDao.getOldestRecord()
|
||||
|
||||
|
@ -897,25 +837,12 @@ import kotlin.math.roundToInt
|
|||
}
|
||||
}
|
||||
|
||||
fun compatGetOfflineEventData(): Single<List<OfflineEvent>> =
|
||||
database.offlineEventDao.getOfflineEventData()
|
||||
.subscribeOn(Schedulers.io())
|
||||
|
||||
fun getOfflineEventDataFromTime(timestamp: Long, ascending: Boolean): Single<List<OfflineEvent>> =
|
||||
database.offlineEventDao.getOfflineEventDataFromTime(timestamp)
|
||||
.map { if (!ascending) it.reversed() else it }
|
||||
.subscribeOn(Schedulers.io())
|
||||
|
||||
fun getOfflineEventDataIncludingInvalidFromTime(timestamp: Long, ascending: Boolean): Single<List<OfflineEvent>> =
|
||||
database.offlineEventDao.getOfflineEventDataIncludingInvalidFromTime(timestamp)
|
||||
.map { if (!ascending) it.reversed() else it }
|
||||
.subscribeOn(Schedulers.io())
|
||||
|
||||
fun getOfflineEventDataFromTimeToTime(start: Long, end: Long, ascending: Boolean): Single<List<OfflineEvent>> =
|
||||
database.offlineEventDao.getOfflineEventDataFromTimeToTime(start, end)
|
||||
.map { if (!ascending) it.reversed() else it }
|
||||
.subscribeOn(Schedulers.io())
|
||||
|
||||
@Suppress("unused")
|
||||
fun getModifiedOfflineEventsDataFromId(lastId: Long): Single<List<OfflineEvent>> =
|
||||
database.offlineEventDao.getModifiedFrom(lastId)
|
||||
.subscribeOn(Schedulers.io())
|
||||
|
@ -925,6 +852,7 @@ import kotlin.math.roundToInt
|
|||
.subscribeOn(Schedulers.io())
|
||||
.toWrappedSingle()
|
||||
|
||||
@Suppress("unused")
|
||||
fun deleteAllOfflineEventEntries() =
|
||||
database.offlineEventDao.deleteAllEntries()
|
||||
|
||||
|
|
|
@ -59,9 +59,6 @@ internal interface BolusDao : TraceableDao<Bolus> {
|
|||
@Query("SELECT * FROM $TABLE_BOLUSES WHERE timestamp >= :timestamp AND referenceId IS NULL ORDER BY id DESC")
|
||||
fun getBolusesIncludingInvalidFromTime(timestamp: Long): Single<List<Bolus>>
|
||||
|
||||
@Query("SELECT * FROM $TABLE_BOLUSES WHERE timestamp >= :from AND timestamp <= :to AND referenceId IS NULL ORDER BY id DESC")
|
||||
fun getBolusesIncludingInvalidFromTimeToTime(from: Long, to: Long): Single<List<Bolus>>
|
||||
|
||||
// This query will be used with v3 to get all changed records
|
||||
@Query("SELECT * FROM $TABLE_BOLUSES WHERE id > :id AND pumpId IS NOT NULL AND type <> :exclude AND referenceId IS NULL OR id IN (SELECT DISTINCT referenceId FROM $TABLE_BOLUSES WHERE id > :id) ORDER BY id ASC")
|
||||
fun getModifiedFrom(id: Long, exclude: Bolus.Type = Bolus.Type.PRIMING): Single<List<Bolus>>
|
||||
|
|
|
@ -46,24 +46,15 @@ internal interface CarbsDao : TraceableDao<Carbs> {
|
|||
@Query("SELECT * FROM $TABLE_CARBS WHERE isValid = 1 AND timestamp + duration >= :timestamp AND referenceId IS NULL ORDER BY id DESC")
|
||||
fun getCarbsFromTimeExpandable(timestamp: Long): Single<List<Carbs>>
|
||||
|
||||
@Query("SELECT * FROM $TABLE_CARBS WHERE isValid = 1 AND timestamp >= :from AND timestamp <= :to AND referenceId IS NULL ORDER BY id DESC")
|
||||
fun getCarbsFromTimeToTime(from: Long, to: Long): Single<List<Carbs>>
|
||||
|
||||
@Query("SELECT * FROM $TABLE_CARBS WHERE isValid = 1 AND timestamp + duration > :from AND timestamp <= :to AND referenceId IS NULL ORDER BY id DESC")
|
||||
fun getCarbsFromTimeToTimeExpandable(from: Long, to: Long): Single<List<Carbs>>
|
||||
|
||||
@Query("SELECT * FROM $TABLE_CARBS WHERE timestamp >= :timestamp AND referenceId IS NULL ORDER BY id DESC")
|
||||
fun getCarbsIncludingInvalidFromTime(timestamp: Long): Single<List<Carbs>>
|
||||
|
||||
@Query("SELECT * FROM $TABLE_CARBS WHERE timestamp + duration >= :timestamp AND referenceId IS NULL ORDER BY id DESC")
|
||||
fun getCarbsIncludingInvalidFromTimeExpandable(timestamp: Long): Single<List<Carbs>>
|
||||
|
||||
@Query("SELECT * FROM $TABLE_CARBS WHERE timestamp >= :from AND timestamp <= :to AND referenceId IS NULL ORDER BY id DESC")
|
||||
fun getCarbsIncludingInvalidFromTimeToTime(from: Long, to: Long): Single<List<Carbs>>
|
||||
|
||||
@Query("SELECT * FROM $TABLE_CARBS WHERE timestamp + duration >= :from AND timestamp <= :to AND referenceId IS NULL ORDER BY id DESC")
|
||||
fun getCarbsIncludingInvalidFromTimeToTimeExpandable(from: Long, to: Long): Single<List<Carbs>>
|
||||
|
||||
// This query will be used with v3 to get all changed records
|
||||
@Query("SELECT * FROM $TABLE_CARBS WHERE id > :id AND referenceId IS NULL OR id IN (SELECT DISTINCT referenceId FROM $TABLE_CARBS WHERE id > :id) ORDER BY id ASC")
|
||||
fun getModifiedFrom(id: Long): Single<List<Carbs>>
|
||||
|
|
|
@ -53,9 +53,6 @@ internal interface ExtendedBolusDao : TraceableDao<ExtendedBolus> {
|
|||
@Query("SELECT * FROM $TABLE_EXTENDED_BOLUSES WHERE timestamp >= :timestamp AND referenceId IS NULL ORDER BY timestamp ASC")
|
||||
fun getExtendedBolusDataIncludingInvalidFromTime(timestamp: Long): Single<List<ExtendedBolus>>
|
||||
|
||||
@Query("SELECT * FROM $TABLE_EXTENDED_BOLUSES WHERE timestamp >= :from AND timestamp <= :to AND referenceId IS NULL ORDER BY timestamp ASC")
|
||||
fun getExtendedBolusDataIncludingInvalidFromTimeToTime(from: Long, to: Long): Single<List<ExtendedBolus>>
|
||||
|
||||
// This query will be used with v3 to get all changed records
|
||||
@Query("SELECT * FROM $TABLE_EXTENDED_BOLUSES WHERE id > :id AND referenceId IS NULL OR id IN (SELECT DISTINCT referenceId FROM $TABLE_EXTENDED_BOLUSES WHERE id > :id) ORDER BY id ASC")
|
||||
fun getModifiedFrom(id: Long): Single<List<ExtendedBolus>>
|
||||
|
|
|
@ -43,12 +43,6 @@ internal interface GlucoseValueDao : TraceableDao<GlucoseValue> {
|
|||
@Query("SELECT * FROM $TABLE_GLUCOSE_VALUES WHERE id > :lastId AND referenceId IS NULL ORDER BY timestamp ASC")
|
||||
fun getDataFromId(lastId: Long): Single<List<GlucoseValue>>
|
||||
|
||||
@Query("SELECT * FROM $TABLE_GLUCOSE_VALUES WHERE id >= :id")
|
||||
fun getAllStartingFrom(id: Long): Single<List<GlucoseValue>>
|
||||
|
||||
@Query("SELECT * FROM $TABLE_GLUCOSE_VALUES WHERE referenceId = :id ORDER BY id DESC LIMIT 1")
|
||||
fun getLastHistoryRecord(id: Long): GlucoseValue?
|
||||
|
||||
// This query will be used with v3 to get all changed records
|
||||
@Query("SELECT * FROM $TABLE_GLUCOSE_VALUES WHERE id > :id AND referenceId IS NULL OR id IN (SELECT DISTINCT referenceId FROM $TABLE_GLUCOSE_VALUES WHERE id > :id) ORDER BY id ASC")
|
||||
fun getModifiedFrom(id: Long): Single<List<GlucoseValue>>
|
||||
|
|
|
@ -31,18 +31,9 @@ internal interface OfflineEventDao : TraceableDao<OfflineEvent> {
|
|||
@Query("SELECT * FROM $TABLE_OFFLINE_EVENTS WHERE timestamp <= :timestamp AND (timestamp + duration) > :timestamp AND referenceId IS NULL AND isValid = 1 ORDER BY timestamp DESC LIMIT 1")
|
||||
fun getOfflineEventActiveAt(timestamp: Long): Maybe<OfflineEvent>
|
||||
|
||||
@Query("SELECT * FROM $TABLE_OFFLINE_EVENTS WHERE timestamp >= :timestamp AND isValid = 1 AND referenceId IS NULL ORDER BY timestamp ASC")
|
||||
fun getOfflineEventDataFromTime(timestamp: Long): Single<List<OfflineEvent>>
|
||||
|
||||
@Query("SELECT * FROM $TABLE_OFFLINE_EVENTS WHERE timestamp >= :timestamp AND referenceId IS NULL ORDER BY timestamp ASC")
|
||||
fun getOfflineEventDataIncludingInvalidFromTime(timestamp: Long): Single<List<OfflineEvent>>
|
||||
|
||||
@Query("SELECT * FROM $TABLE_OFFLINE_EVENTS WHERE timestamp BETWEEN :start AND :end AND isValid = 1 AND referenceId IS NULL ORDER BY timestamp ASC")
|
||||
fun getOfflineEventDataFromTimeToTime(start: Long, end: Long): Single<List<OfflineEvent>>
|
||||
|
||||
@Query("SELECT * FROM $TABLE_OFFLINE_EVENTS WHERE isValid = 1 AND referenceId IS NULL ORDER BY timestamp ASC")
|
||||
fun getOfflineEventData(): Single<List<OfflineEvent>>
|
||||
|
||||
// This query will be used with v3 to get all changed records
|
||||
@Query("SELECT * FROM $TABLE_OFFLINE_EVENTS WHERE id > :id AND referenceId IS NULL OR id IN (SELECT DISTINCT referenceId FROM $TABLE_OFFLINE_EVENTS WHERE id > :id) ORDER BY id ASC")
|
||||
fun getModifiedFrom(id: Long): Single<List<OfflineEvent>>
|
||||
|
|
|
@ -62,12 +62,6 @@ internal interface TemporaryBasalDao : TraceableDao<TemporaryBasal> {
|
|||
@Query("SELECT * FROM $TABLE_TEMPORARY_BASALS WHERE timestamp >= :timestamp AND referenceId IS NULL ORDER BY timestamp ASC")
|
||||
fun getTemporaryBasalDataIncludingInvalidFromTime(timestamp: Long): Single<List<TemporaryBasal>>
|
||||
|
||||
@Query("SELECT * FROM $TABLE_TEMPORARY_BASALS WHERE timestamp >= :from AND timestamp <= :to AND referenceId IS NULL ORDER BY timestamp ASC")
|
||||
fun getTemporaryBasalDataIncludingInvalidFromTimeToTime(from: Long, to: Long): Single<List<TemporaryBasal>>
|
||||
|
||||
@Query("SELECT * FROM $TABLE_TEMPORARY_BASALS WHERE isValid = 1 AND referenceId IS NULL ORDER BY timestamp ASC")
|
||||
fun getTemporaryBasalData(): Single<List<TemporaryBasal>>
|
||||
|
||||
@Query("SELECT * FROM $TABLE_TEMPORARY_BASALS WHERE referenceId = :id ORDER BY id DESC LIMIT 1")
|
||||
fun getLastHistoryRecord(id: Long): TemporaryBasal?
|
||||
|
||||
|
|
|
@ -37,9 +37,6 @@ internal interface TemporaryTargetDao : TraceableDao<TemporaryTarget> {
|
|||
@Query("SELECT * FROM $TABLE_TEMPORARY_TARGETS WHERE timestamp >= :timestamp AND referenceId IS NULL ORDER BY timestamp ASC")
|
||||
fun getTemporaryTargetDataIncludingInvalidFromTime(timestamp: Long): Single<List<TemporaryTarget>>
|
||||
|
||||
@Query("SELECT * FROM $TABLE_TEMPORARY_TARGETS WHERE isValid = 1 AND referenceId IS NULL ORDER BY timestamp ASC")
|
||||
fun getTemporaryTargetData(): Single<List<TemporaryTarget>>
|
||||
|
||||
// This query will be used with v3 to get all changed records
|
||||
@Query("SELECT * FROM $TABLE_TEMPORARY_TARGETS WHERE id > :id AND referenceId IS NULL OR id IN (SELECT DISTINCT referenceId FROM $TABLE_TEMPORARY_TARGETS WHERE id > :id) ORDER BY id ASC")
|
||||
fun getModifiedFrom(id: Long): Single<List<TemporaryTarget>>
|
||||
|
|
|
@ -46,9 +46,6 @@ internal interface TherapyEventDao : TraceableDao<TherapyEvent> {
|
|||
@Query("SELECT * FROM $TABLE_THERAPY_EVENTS WHERE type = :type AND isValid = 1 AND timestamp <= :now ORDER BY timestamp DESC LIMIT 1")
|
||||
fun getLastTherapyRecord(type: TherapyEvent.Type, now: Long): Maybe<TherapyEvent>
|
||||
|
||||
@Query("SELECT * FROM $TABLE_THERAPY_EVENTS WHERE timestamp >= :timestamp AND isValid = 1 AND referenceId IS NULL ORDER BY timestamp ASC")
|
||||
fun compatGetTherapyEventDataFromTime(timestamp: Long): Single<List<TherapyEvent>>
|
||||
|
||||
@Query("SELECT * FROM $TABLE_THERAPY_EVENTS WHERE timestamp >= :from AND timestamp <= :to AND isValid = 1 AND referenceId IS NULL ORDER BY timestamp ASC")
|
||||
fun compatGetTherapyEventDataFromToTime(from: Long, to: Long): Single<List<TherapyEvent>>
|
||||
|
||||
|
|
|
@ -3,8 +3,9 @@ package info.nightscout.database.impl.daos
|
|||
import androidx.room.Insert
|
||||
import androidx.room.Update
|
||||
import info.nightscout.database.entities.interfaces.TraceableDBEntry
|
||||
import info.nightscout.database.impl.daos.workaround.TraceableDaoWorkaround
|
||||
|
||||
internal interface TraceableDao<T : TraceableDBEntry> : info.nightscout.database.impl.daos.workaround.TraceableDaoWorkaround<T> {
|
||||
internal interface TraceableDao<T : TraceableDBEntry> : TraceableDaoWorkaround<T> {
|
||||
|
||||
fun findById(id: Long): T?
|
||||
|
||||
|
|
|
@ -17,9 +17,6 @@ interface UserEntryDao {
|
|||
@Query("DELETE FROM $TABLE_USER_ENTRY WHERE timestamp < :than")
|
||||
fun deleteOlderThan(than: Long): Int
|
||||
|
||||
@Query("SELECT * FROM $TABLE_USER_ENTRY ORDER BY id DESC")
|
||||
fun getAll(): Single<List<UserEntry>>
|
||||
|
||||
@Query("SELECT * FROM $TABLE_USER_ENTRY WHERE timestamp >= :timestamp ORDER BY id DESC")
|
||||
fun getUserEntryDataFromTime(timestamp: Long): Single<List<UserEntry>>
|
||||
|
||||
|
|
|
@ -105,8 +105,7 @@ class TreatmentsTempTargetFragment : DaggerFragment(), MenuProvider {
|
|||
uel.log(Action.TREATMENTS_NS_REFRESH, Sources.Treatments)
|
||||
disposable +=
|
||||
Completable.fromAction {
|
||||
repository.deleteAllEffectiveProfileSwitches()
|
||||
repository.deleteAllProfileSwitches()
|
||||
repository.deleteAllTempTargetEntries()
|
||||
}
|
||||
.subscribeOn(aapsSchedulers.io)
|
||||
.observeOn(aapsSchedulers.main)
|
||||
|
|
Loading…
Reference in a new issue