|
|
@ -7,9 +7,9 @@ package com.todoroo.astrid.dao;
|
|
|
|
|
|
|
|
|
|
|
|
import static com.todoroo.andlib.utility.DateUtilities.now;
|
|
|
|
import static com.todoroo.andlib.utility.DateUtilities.now;
|
|
|
|
|
|
|
|
|
|
|
|
import android.arch.persistence.room.Dao;
|
|
|
|
import androidx.room.Dao;
|
|
|
|
import android.arch.persistence.room.Insert;
|
|
|
|
import androidx.room.Insert;
|
|
|
|
import android.arch.persistence.room.Update;
|
|
|
|
import androidx.room.Update;
|
|
|
|
import android.content.Context;
|
|
|
|
import android.content.Context;
|
|
|
|
import android.database.Cursor;
|
|
|
|
import android.database.Cursor;
|
|
|
|
import com.todoroo.andlib.data.Property;
|
|
|
|
import com.todoroo.andlib.data.Property;
|
|
|
@ -47,48 +47,48 @@ public abstract class TaskDao {
|
|
|
|
return needsRefresh(now());
|
|
|
|
return needsRefresh(now());
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
@android.arch.persistence.room.Query(
|
|
|
|
@androidx.room.Query(
|
|
|
|
"SELECT * FROM tasks WHERE completed = 0 AND deleted = 0 AND (hideUntil > :now OR dueDate > :now)")
|
|
|
|
"SELECT * FROM tasks WHERE completed = 0 AND deleted = 0 AND (hideUntil > :now OR dueDate > :now)")
|
|
|
|
abstract List<Task> needsRefresh(long now);
|
|
|
|
abstract List<Task> needsRefresh(long now);
|
|
|
|
|
|
|
|
|
|
|
|
@android.arch.persistence.room.Query("SELECT * FROM tasks WHERE _id = :id LIMIT 1")
|
|
|
|
@androidx.room.Query("SELECT * FROM tasks WHERE _id = :id LIMIT 1")
|
|
|
|
public abstract Task fetch(long id);
|
|
|
|
public abstract Task fetch(long id);
|
|
|
|
|
|
|
|
|
|
|
|
@android.arch.persistence.room.Query("SELECT * FROM tasks WHERE _id IN (:taskIds)")
|
|
|
|
@androidx.room.Query("SELECT * FROM tasks WHERE _id IN (:taskIds)")
|
|
|
|
public abstract List<Task> fetch(List<Long> taskIds);
|
|
|
|
public abstract List<Task> fetch(List<Long> taskIds);
|
|
|
|
|
|
|
|
|
|
|
|
@android.arch.persistence.room.Query(
|
|
|
|
@androidx.room.Query(
|
|
|
|
"SELECT COUNT(1) FROM tasks WHERE timerStart > 0 AND deleted = 0")
|
|
|
|
"SELECT COUNT(1) FROM tasks WHERE timerStart > 0 AND deleted = 0")
|
|
|
|
public abstract int activeTimers();
|
|
|
|
public abstract int activeTimers();
|
|
|
|
|
|
|
|
|
|
|
|
@android.arch.persistence.room.Query(
|
|
|
|
@androidx.room.Query(
|
|
|
|
"SELECT tasks.* FROM tasks INNER JOIN notification ON tasks._id = notification.task")
|
|
|
|
"SELECT tasks.* FROM tasks INNER JOIN notification ON tasks._id = notification.task")
|
|
|
|
public abstract List<Task> activeNotifications();
|
|
|
|
public abstract List<Task> activeNotifications();
|
|
|
|
|
|
|
|
|
|
|
|
@android.arch.persistence.room.Query("SELECT * FROM tasks WHERE remoteId = :remoteId")
|
|
|
|
@androidx.room.Query("SELECT * FROM tasks WHERE remoteId = :remoteId")
|
|
|
|
public abstract Task fetch(String remoteId);
|
|
|
|
public abstract Task fetch(String remoteId);
|
|
|
|
|
|
|
|
|
|
|
|
@android.arch.persistence.room.Query("SELECT * FROM tasks WHERE completed = 0 AND deleted = 0")
|
|
|
|
@androidx.room.Query("SELECT * FROM tasks WHERE completed = 0 AND deleted = 0")
|
|
|
|
abstract List<Task> getActiveTasks();
|
|
|
|
abstract List<Task> getActiveTasks();
|
|
|
|
|
|
|
|
|
|
|
|
@android.arch.persistence.room.Query(
|
|
|
|
@androidx.room.Query(
|
|
|
|
"SELECT * FROM tasks WHERE hideUntil < (strftime('%s','now')*1000)")
|
|
|
|
"SELECT * FROM tasks WHERE hideUntil < (strftime('%s','now')*1000)")
|
|
|
|
abstract List<Task> getVisibleTasks();
|
|
|
|
abstract List<Task> getVisibleTasks();
|
|
|
|
|
|
|
|
|
|
|
|
@android.arch.persistence.room.Query(
|
|
|
|
@androidx.room.Query(
|
|
|
|
"SELECT * FROM tasks WHERE remoteId IN (:remoteIds) "
|
|
|
|
"SELECT * FROM tasks WHERE remoteId IN (:remoteIds) "
|
|
|
|
+ "AND recurrence NOT NULL AND LENGTH(recurrence) > 0")
|
|
|
|
+ "AND recurrence NOT NULL AND LENGTH(recurrence) > 0")
|
|
|
|
public abstract List<Task> getRecurringTasks(List<String> remoteIds);
|
|
|
|
public abstract List<Task> getRecurringTasks(List<String> remoteIds);
|
|
|
|
|
|
|
|
|
|
|
|
@android.arch.persistence.room.Query(
|
|
|
|
@androidx.room.Query(
|
|
|
|
"UPDATE tasks SET completed = :completionDate " + "WHERE remoteId = :remoteId")
|
|
|
|
"UPDATE tasks SET completed = :completionDate " + "WHERE remoteId = :remoteId")
|
|
|
|
public abstract void setCompletionDate(String remoteId, long completionDate);
|
|
|
|
public abstract void setCompletionDate(String remoteId, long completionDate);
|
|
|
|
|
|
|
|
|
|
|
|
@android.arch.persistence.room.Query(
|
|
|
|
@androidx.room.Query(
|
|
|
|
"UPDATE tasks SET snoozeTime = :millis WHERE _id in (:taskIds)")
|
|
|
|
"UPDATE tasks SET snoozeTime = :millis WHERE _id in (:taskIds)")
|
|
|
|
public abstract void snooze(List<Long> taskIds, long millis);
|
|
|
|
public abstract void snooze(List<Long> taskIds, long millis);
|
|
|
|
|
|
|
|
|
|
|
|
@android.arch.persistence.room.Query(
|
|
|
|
@androidx.room.Query(
|
|
|
|
"SELECT tasks.* FROM tasks "
|
|
|
|
"SELECT tasks.* FROM tasks "
|
|
|
|
+ "LEFT JOIN google_tasks ON tasks._id = google_tasks.task "
|
|
|
|
+ "LEFT JOIN google_tasks ON tasks._id = google_tasks.task "
|
|
|
|
+ "WHERE list_id IN (SELECT remote_id FROM google_task_lists WHERE account = :account)"
|
|
|
|
+ "WHERE list_id IN (SELECT remote_id FROM google_task_lists WHERE account = :account)"
|
|
|
@ -96,37 +96,37 @@ public abstract class TaskDao {
|
|
|
|
+ "OR google_tasks.remote_id = '')")
|
|
|
|
+ "OR google_tasks.remote_id = '')")
|
|
|
|
public abstract List<Task> getGoogleTasksToPush(String account);
|
|
|
|
public abstract List<Task> getGoogleTasksToPush(String account);
|
|
|
|
|
|
|
|
|
|
|
|
@android.arch.persistence.room.Query(
|
|
|
|
@androidx.room.Query(
|
|
|
|
"SELECT tasks.* FROM tasks "
|
|
|
|
"SELECT tasks.* FROM tasks "
|
|
|
|
+ "LEFT JOIN caldav_tasks ON tasks._id = caldav_tasks.task "
|
|
|
|
+ "LEFT JOIN caldav_tasks ON tasks._id = caldav_tasks.task "
|
|
|
|
+ "WHERE caldav_tasks.calendar = :calendar "
|
|
|
|
+ "WHERE caldav_tasks.calendar = :calendar "
|
|
|
|
+ "AND tasks.modified > caldav_tasks.last_sync")
|
|
|
|
+ "AND tasks.modified > caldav_tasks.last_sync")
|
|
|
|
public abstract List<Task> getCaldavTasksToPush(String calendar);
|
|
|
|
public abstract List<Task> getCaldavTasksToPush(String calendar);
|
|
|
|
|
|
|
|
|
|
|
|
@android.arch.persistence.room.Query(
|
|
|
|
@androidx.room.Query(
|
|
|
|
"SELECT * FROM TASKS "
|
|
|
|
"SELECT * FROM TASKS "
|
|
|
|
+ "WHERE completed = 0 AND deleted = 0 AND (notificationFlags > 0 OR notifications > 0)")
|
|
|
|
+ "WHERE completed = 0 AND deleted = 0 AND (notificationFlags > 0 OR notifications > 0)")
|
|
|
|
public abstract List<Task> getTasksWithReminders();
|
|
|
|
public abstract List<Task> getTasksWithReminders();
|
|
|
|
|
|
|
|
|
|
|
|
// --- SQL clause generators
|
|
|
|
// --- SQL clause generators
|
|
|
|
|
|
|
|
|
|
|
|
@android.arch.persistence.room.Query("SELECT * FROM tasks")
|
|
|
|
@androidx.room.Query("SELECT * FROM tasks")
|
|
|
|
public abstract List<Task> getAll();
|
|
|
|
public abstract List<Task> getAll();
|
|
|
|
|
|
|
|
|
|
|
|
@android.arch.persistence.room.Query(
|
|
|
|
@androidx.room.Query(
|
|
|
|
"SELECT calendarUri FROM tasks " + "WHERE calendarUri NOT NULL AND calendarUri != ''")
|
|
|
|
"SELECT calendarUri FROM tasks " + "WHERE calendarUri NOT NULL AND calendarUri != ''")
|
|
|
|
public abstract List<String> getAllCalendarEvents();
|
|
|
|
public abstract List<String> getAllCalendarEvents();
|
|
|
|
|
|
|
|
|
|
|
|
@android.arch.persistence.room.Query(
|
|
|
|
@androidx.room.Query(
|
|
|
|
"UPDATE tasks SET calendarUri = '' " + "WHERE calendarUri NOT NULL AND calendarUri != ''")
|
|
|
|
"UPDATE tasks SET calendarUri = '' " + "WHERE calendarUri NOT NULL AND calendarUri != ''")
|
|
|
|
public abstract int clearAllCalendarEvents();
|
|
|
|
public abstract int clearAllCalendarEvents();
|
|
|
|
|
|
|
|
|
|
|
|
@android.arch.persistence.room.Query(
|
|
|
|
@androidx.room.Query(
|
|
|
|
"SELECT calendarUri FROM tasks "
|
|
|
|
"SELECT calendarUri FROM tasks "
|
|
|
|
+ "WHERE completed > 0 AND calendarUri NOT NULL AND calendarUri != ''")
|
|
|
|
+ "WHERE completed > 0 AND calendarUri NOT NULL AND calendarUri != ''")
|
|
|
|
public abstract List<String> getCompletedCalendarEvents();
|
|
|
|
public abstract List<String> getCompletedCalendarEvents();
|
|
|
|
|
|
|
|
|
|
|
|
@android.arch.persistence.room.Query(
|
|
|
|
@androidx.room.Query(
|
|
|
|
"UPDATE tasks SET calendarUri = '' "
|
|
|
|
"UPDATE tasks SET calendarUri = '' "
|
|
|
|
+ "WHERE completed > 0 AND calendarUri NOT NULL AND calendarUri != ''")
|
|
|
|
+ "WHERE completed > 0 AND calendarUri NOT NULL AND calendarUri != ''")
|
|
|
|
public abstract int clearCompletedCalendarEvents();
|
|
|
|
public abstract int clearCompletedCalendarEvents();
|
|
|
@ -178,7 +178,7 @@ public abstract class TaskDao {
|
|
|
|
return false;
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
@android.arch.persistence.room.Query(
|
|
|
|
@androidx.room.Query(
|
|
|
|
"SELECT * FROM tasks "
|
|
|
|
"SELECT * FROM tasks "
|
|
|
|
+ "WHERE completed = 0 AND deleted = 0 AND hideUntil < (strftime('%s','now')*1000) "
|
|
|
|
+ "WHERE completed = 0 AND deleted = 0 AND hideUntil < (strftime('%s','now')*1000) "
|
|
|
|
+ "ORDER BY (CASE WHEN (dueDate=0) THEN (strftime('%s','now')*1000)*2 ELSE ((CASE WHEN (dueDate / 60000) > 0 THEN dueDate ELSE (dueDate + 43140000) END)) END) + 172800000 * importance ASC "
|
|
|
|
+ "ORDER BY (CASE WHEN (dueDate=0) THEN (strftime('%s','now')*1000)*2 ELSE ((CASE WHEN (dueDate / 60000) > 0 THEN dueDate ELSE (dueDate + 43140000) END)) END) + 172800000 * importance ASC "
|
|
|
|