Add default timestamp argument to dao methods

pull/1012/head
Alex Baker 4 years ago
parent 998d07d34e
commit 6487180e38

@ -130,7 +130,7 @@ class CaldavDaoTests : InjectingTestCase() {
val caldavAccount = CaldavAccount() val caldavAccount = CaldavAccount()
caldavAccount.uuid = UUIDHelper.newUUID() caldavAccount.uuid = UUIDHelper.newUUID()
caldavDao.insert(caldavAccount) caldavDao.insert(caldavAccount)
assertTrue(caldavDao.getCaldavFilters(caldavAccount.uuid!!, DateUtilities.now()).isEmpty()) assertTrue(caldavDao.getCaldavFilters(caldavAccount.uuid!!).isEmpty())
} }
private fun checkOrder(dateTime: DateTime, task: Long) = checkOrder(dateTime.toAppleEpoch(), task) private fun checkOrder(dateTime: DateTime, task: Long) = checkOrder(dateTime.toAppleEpoch(), task)

@ -2,7 +2,6 @@ package org.tasks.data
import androidx.test.ext.junit.runners.AndroidJUnit4 import androidx.test.ext.junit.runners.AndroidJUnit4
import com.natpryce.makeiteasy.MakeItEasy.with import com.natpryce.makeiteasy.MakeItEasy.with
import com.todoroo.andlib.utility.DateUtilities.now
import org.junit.Assert.* import org.junit.Assert.*
import org.junit.Test import org.junit.Test
import org.junit.runner.RunWith import org.junit.runner.RunWith
@ -24,7 +23,7 @@ class GoogleTaskListDaoTest : InjectingTestCase() {
account.account = "user@gmail.com" account.account = "user@gmail.com"
googleTaskListDao.insert(account) googleTaskListDao.insert(account)
assertTrue(googleTaskListDao.getGoogleTaskFilters(account.account!!, now()).isEmpty()) assertTrue(googleTaskListDao.getGoogleTaskFilters(account.account!!).isEmpty())
} }
@Test @Test

@ -175,7 +175,7 @@ abstract class CaldavDao {
+ " LEFT JOIN tasks ON caldav_tasks.cd_task = tasks._id AND tasks.deleted = 0 AND tasks.completed = 0 AND tasks.hideUntil < :now AND cd_deleted = 0" + " LEFT JOIN tasks ON caldav_tasks.cd_task = tasks._id AND tasks.deleted = 0 AND tasks.completed = 0 AND tasks.hideUntil < :now AND cd_deleted = 0"
+ " WHERE caldav_lists.cdl_account = :uuid" + " WHERE caldav_lists.cdl_account = :uuid"
+ " GROUP BY caldav_lists.cdl_uuid") + " GROUP BY caldav_lists.cdl_uuid")
abstract fun getCaldavFilters(uuid: String, now: Long): List<CaldavFilters> abstract fun getCaldavFilters(uuid: String, now: Long = currentTimeMillis()): List<CaldavFilters>
@Query("SELECT tasks._id FROM tasks " @Query("SELECT tasks._id FROM tasks "
+ "INNER JOIN tags ON tags.task = tasks._id " + "INNER JOIN tags ON tags.task = tasks._id "

@ -4,6 +4,7 @@ import androidx.lifecycle.LiveData
import androidx.room.* import androidx.room.*
import io.reactivex.Single import io.reactivex.Single
import org.tasks.filters.GoogleTaskFilters import org.tasks.filters.GoogleTaskFilters
import org.tasks.time.DateTimeUtils.currentTimeMillis
@Dao @Dao
interface GoogleTaskListDao { interface GoogleTaskListDao {
@ -61,5 +62,5 @@ interface GoogleTaskListDao {
+ " LEFT JOIN tasks ON google_tasks.gt_task = tasks._id AND tasks.deleted = 0 AND tasks.completed = 0 AND tasks.hideUntil < :now AND gt_deleted = 0" + " LEFT JOIN tasks ON google_tasks.gt_task = tasks._id AND tasks.deleted = 0 AND tasks.completed = 0 AND tasks.hideUntil < :now AND gt_deleted = 0"
+ " WHERE google_task_lists.gtl_account = :account" + " WHERE google_task_lists.gtl_account = :account"
+ " GROUP BY google_task_lists.gtl_remote_id") + " GROUP BY google_task_lists.gtl_remote_id")
fun getGoogleTaskFilters(account: String, now: Long): List<GoogleTaskFilters> fun getGoogleTaskFilters(account: String, now: Long = currentTimeMillis()): List<GoogleTaskFilters>
} }

@ -244,7 +244,7 @@ class FilterProvider @Inject constructor(
emptyList() emptyList()
} else { } else {
googleTaskListDao googleTaskListDao
.getGoogleTaskFilters(account.account!!, DateUtilities.now()) .getGoogleTaskFilters(account.account!!)
.map(GoogleTaskFilters::toGtasksFilter) .map(GoogleTaskFilters::toGtasksFilter)
.sortedWith(AlphanumComparator.FILTER) .sortedWith(AlphanumComparator.FILTER)
} }
@ -266,7 +266,7 @@ class FilterProvider @Inject constructor(
emptyList() emptyList()
} else { } else {
caldavDao caldavDao
.getCaldavFilters(account.uuid!!, DateUtilities.now()) .getCaldavFilters(account.uuid!!)
.map(CaldavFilters::toCaldavFilter) .map(CaldavFilters::toCaldavFilter)
.sortedWith(AlphanumComparator.FILTER) .sortedWith(AlphanumComparator.FILTER)
} }

Loading…
Cancel
Save