feat(eros-database): invert time comparison to fix allSince DAO queries
This commit is contained in:
parent
289ec5668d
commit
0f68f71106
|
@ -37,18 +37,16 @@ class ErosHistoryTest {
|
|||
var history = erosHistory.getAllErosHistoryRecordsFromTimestamp(0L, true);
|
||||
assert(history.isEmpty())
|
||||
|
||||
val type = PodHistoryEntryType.SET_BOLUS.code
|
||||
val entity = ErosHistoryRecordEntity(1000L, type.toLong())
|
||||
val type = PodHistoryEntryType.SET_BOLUS.code.toLong()
|
||||
val entity = ErosHistoryRecordEntity(1000L, type)
|
||||
erosHistory.create(entity)
|
||||
erosHistory.create(ErosHistoryRecordEntity(3000L, PodHistoryEntryType.CANCEL_BOLUS.code.toLong()))
|
||||
|
||||
history = erosHistory.getAllErosHistoryRecordsFromTimestamp(0L, true);
|
||||
assert(!history.isEmpty())
|
||||
assert(history.size == 2)
|
||||
assert(type.equals(history.first().podEntryTypeCode))
|
||||
|
||||
history = erosHistory.getAllErosHistoryRecordsFromTimestamp(0L, false);
|
||||
assert(!history.isEmpty())
|
||||
assert(history.size == 2)
|
||||
assert(type.equals(history.last().podEntryTypeCode))
|
||||
|
||||
|
|
|
@ -4,14 +4,15 @@ import androidx.room.Dao
|
|||
import androidx.room.Insert
|
||||
import androidx.room.OnConflictStrategy
|
||||
import androidx.room.Query
|
||||
import androidx.room.Transaction
|
||||
|
||||
@Dao
|
||||
interface ErosHistoryRecordDao {
|
||||
|
||||
@Query("SELECT * from historyrecords WHERE date <= :since order by date asc")
|
||||
@Query("SELECT * from historyrecords WHERE date >= :since order by date asc")
|
||||
fun allSinceAsc(since: Long): List<ErosHistoryRecordEntity>
|
||||
|
||||
@Query("SELECT * from historyrecords WHERE date <= :since order by date desc")
|
||||
@Query("SELECT * from historyrecords WHERE date >= :since order by date desc")
|
||||
fun allSinceDesc(since: Long): List<ErosHistoryRecordEntity>
|
||||
|
||||
@Query("SELECT * FROM historyrecords WHERE pumpId = :id LIMIT 1")
|
||||
|
|
Loading…
Reference in a new issue