expandable carbs query extended
This commit is contained in:
parent
d9ceeb043e
commit
93b1b37021
|
@ -312,7 +312,6 @@ open class AppRepository @Inject internal constructor(
|
|||
|
||||
// CARBS
|
||||
|
||||
val timeBackForExpand = 8 * 60 * 60 * 1000
|
||||
private fun expandCarbs(carbs: Carbs): List<Carbs> =
|
||||
if (carbs.duration == 0L) {
|
||||
listOf(carbs)
|
||||
|
@ -377,8 +376,9 @@ open class AppRepository @Inject internal constructor(
|
|||
.subscribeOn(Schedulers.io())
|
||||
|
||||
fun getCarbsDataFromTimeExpanded(timestamp: Long, ascending: Boolean): Single<List<Carbs>> =
|
||||
database.carbsDao.getCarbsFromTime(timestamp - timeBackForExpand)
|
||||
database.carbsDao.getCarbsFromTimeExpandable(timestamp)
|
||||
.expand()
|
||||
.from(timestamp)
|
||||
.map { if (!ascending) it.reversed() else it }
|
||||
.subscribeOn(Schedulers.io())
|
||||
|
||||
|
@ -396,7 +396,14 @@ open class AppRepository @Inject internal constructor(
|
|||
.subscribeOn(Schedulers.io())
|
||||
|
||||
fun getCarbsIncludingInvalidFromTime(timestamp: Long, ascending: Boolean): Single<List<Carbs>> =
|
||||
database.carbsDao.getCarbsIncludingInvalidFromTime(timestamp - timeBackForExpand)
|
||||
database.carbsDao.getCarbsIncludingInvalidFromTime(timestamp)
|
||||
.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())
|
||||
|
||||
|
|
|
@ -35,6 +35,9 @@ internal interface CarbsDao : TraceableDao<Carbs> {
|
|||
@Query("SELECT * FROM $TABLE_CARBS WHERE isValid = 1 AND timestamp >= :timestamp AND referenceId IS NULL ORDER BY id DESC")
|
||||
fun getCarbsFromTime(timestamp: Long): Single<List<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>>
|
||||
|
||||
|
@ -44,10 +47,13 @@ internal interface CarbsDao : TraceableDao<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 >= :from AND timestamp <= :to AND referenceId IS NULL ORDER BY id DESC")
|
||||
@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
|
||||
|
|
Loading…
Reference in a new issue