From 85df281b73885f90e3ff01aa94704f7f8ccdf38a Mon Sep 17 00:00:00 2001 From: Milos Kozak Date: Thu, 12 Jan 2023 14:06:24 +0100 Subject: [PATCH] fix SQL query --- .../nightscout/database/impl/daos/EffectiveProfileSwitchDao.kt | 2 +- .../java/info/nightscout/database/impl/daos/TherapyEventDao.kt | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/database/impl/src/main/java/info/nightscout/database/impl/daos/EffectiveProfileSwitchDao.kt b/database/impl/src/main/java/info/nightscout/database/impl/daos/EffectiveProfileSwitchDao.kt index 5fa4b6b233..74c38cd7ce 100644 --- a/database/impl/src/main/java/info/nightscout/database/impl/daos/EffectiveProfileSwitchDao.kt +++ b/database/impl/src/main/java/info/nightscout/database/impl/daos/EffectiveProfileSwitchDao.kt @@ -31,7 +31,7 @@ internal interface EffectiveProfileSwitchDao : TraceableDao= timestamp AND referenceId IS NULL AND isValid = 1 ORDER BY timestamp DESC LIMIT 1") diff --git a/database/impl/src/main/java/info/nightscout/database/impl/daos/TherapyEventDao.kt b/database/impl/src/main/java/info/nightscout/database/impl/daos/TherapyEventDao.kt index 8150021416..366d06b5bf 100644 --- a/database/impl/src/main/java/info/nightscout/database/impl/daos/TherapyEventDao.kt +++ b/database/impl/src/main/java/info/nightscout/database/impl/daos/TherapyEventDao.kt @@ -43,7 +43,7 @@ internal interface TherapyEventDao : TraceableDao { @Query("SELECT * FROM $TABLE_THERAPY_EVENTS WHERE timestamp >= :timestamp AND referenceId IS NULL ORDER BY timestamp ASC") fun getTherapyEventDataIncludingInvalidFromTime(timestamp: Long): Single> - @Query("SELECT * FROM $TABLE_THERAPY_EVENTS WHERE type = :type AND isValid = 1 AND timestamp <= :now ORDER BY id DESC LIMIT 1") + @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 @Query("SELECT * FROM $TABLE_THERAPY_EVENTS WHERE timestamp >= :timestamp AND isValid = 1 AND referenceId IS NULL ORDER BY timestamp ASC")