Remove google task children from list of ids

gtask_related_email
Alex Baker 5 years ago
parent b9a5e1cf02
commit 48fdba8884

@ -64,10 +64,6 @@ public abstract class TaskDao {
@Query("SELECT * FROM tasks WHERE _id IN (:taskIds)") @Query("SELECT * FROM tasks WHERE _id IN (:taskIds)")
public abstract List<Task> fetch(List<Long> taskIds); public abstract List<Task> fetch(List<Long> taskIds);
@Query(
"SELECT tasks.* FROM tasks LEFT JOIN google_tasks ON gt_task = _id WHERE _id IN (:taskIds) AND (gt_task IS NULL OR gt_parent NOT IN (:taskIds))")
public abstract List<Task> fetchExcludingChildren(List<Long> taskIds);
@Query("SELECT COUNT(1) FROM tasks WHERE timerStart > 0 AND deleted = 0") @Query("SELECT COUNT(1) FROM tasks WHERE timerStart > 0 AND deleted = 0")
public abstract int activeTimers(); public abstract int activeTimers();

@ -2,6 +2,7 @@ package com.todoroo.astrid.service;
import static com.google.common.collect.Iterables.concat; import static com.google.common.collect.Iterables.concat;
import static com.google.common.collect.Iterables.transform; import static com.google.common.collect.Iterables.transform;
import static com.google.common.collect.Lists.newArrayList;
import static com.google.common.collect.Lists.transform; import static com.google.common.collect.Lists.transform;
import static com.todoroo.andlib.utility.DateUtilities.now; import static com.todoroo.andlib.utility.DateUtilities.now;
import static java.util.Collections.emptyList; import static java.util.Collections.emptyList;
@ -48,8 +49,9 @@ public class TaskMover {
} }
public void move(List<Long> tasks, Filter selectedList) { public void move(List<Long> tasks, Filter selectedList) {
List<Task> fetch = taskDao.fetchExcludingChildren(tasks); tasks = newArrayList(tasks);
for (Task task : fetch) { tasks.removeAll(googleTaskDao.findChildrenInList(tasks));
for (Task task : taskDao.fetch(tasks)) {
performMove(task, selectedList); performMove(task, selectedList);
task.putTransitory(SyncFlags.GTASKS_SUPPRESS_SYNC, true); task.putTransitory(SyncFlags.GTASKS_SUPPRESS_SYNC, true);
task.setModificationDate(now()); task.setModificationDate(now());

@ -98,6 +98,9 @@ public abstract class GoogleTaskDao {
@Query("SELECT tasks.* FROM tasks JOIN google_tasks ON tasks._id = gt_task WHERE gt_parent = :taskId") @Query("SELECT tasks.* FROM tasks JOIN google_tasks ON tasks._id = gt_task WHERE gt_parent = :taskId")
public abstract List<Task> getChildTasks(long taskId); public abstract List<Task> getChildTasks(long taskId);
@Query("SELECT gt_task FROM google_tasks WHERE gt_task IN (:taskIds) AND gt_parent IN (:taskIds)")
public abstract List<Long> findChildrenInList(List<Long> taskIds);
@Query("SELECT * FROM google_tasks WHERE gt_parent = :id AND gt_deleted = 0") @Query("SELECT * FROM google_tasks WHERE gt_parent = :id AND gt_deleted = 0")
public abstract List<GoogleTask> getChildren(Long id); public abstract List<GoogleTask> getChildren(Long id);

Loading…
Cancel
Save