Fix clear completed from recently modified filter

pull/935/head
Alex Baker 5 years ago
parent 1f691cebb8
commit 8d4a00d459

@ -1,6 +1,7 @@
package com.todoroo.astrid.service; package com.todoroo.astrid.service;
import static org.tasks.db.DbUtils.collect; import static org.tasks.db.DbUtils.collect;
import static org.tasks.db.QueryUtils.removeOrder;
import static org.tasks.db.QueryUtils.showHiddenAndCompleted; import static org.tasks.db.QueryUtils.showHiddenAndCompleted;
import com.google.common.collect.ImmutableList; import com.google.common.collect.ImmutableList;
@ -87,7 +88,8 @@ public class TaskDeleter {
public int clearCompleted(Filter filter) { public int clearCompleted(Filter filter) {
List<Long> completed = new ArrayList<>(); List<Long> completed = new ArrayList<>();
Filter deleteFilter = new Filter(null, null); Filter deleteFilter = new Filter(null, null);
deleteFilter.setFilterQueryOverride(showHiddenAndCompleted(filter.getOriginalSqlQuery())); deleteFilter.setFilterQueryOverride(
removeOrder(showHiddenAndCompleted(filter.getOriginalSqlQuery())));
List<TaskContainer> tasks = List<TaskContainer> tasks =
taskDao.fetchTasks( taskDao.fetchTasks(
(includeGoogleSubtasks, includeCaldavSubtasks) -> (includeGoogleSubtasks, includeCaldavSubtasks) ->

@ -12,6 +12,9 @@ public class QueryUtils {
private static final Pattern UNCOMPLETED = Pattern.compile("tasks\\.completed<?=0"); private static final Pattern UNCOMPLETED = Pattern.compile("tasks\\.completed<?=0");
private static final Pattern ORDER =
Pattern.compile("order by .*? (asc|desc)", Pattern.CASE_INSENSITIVE);
public static String showHidden(String query) { public static String showHidden(String query) {
return HIDDEN.matcher(query).replaceAll("1"); return HIDDEN.matcher(query).replaceAll("1");
} }
@ -33,4 +36,8 @@ public class QueryUtils {
Task.COMPLETION_DATE.gte(DateUtilities.now() - 59999)) Task.COMPLETION_DATE.gte(DateUtilities.now() - 59999))
.toString()); .toString());
} }
public static String removeOrder(String query) {
return ORDER.matcher(query).replaceAll("");
}
} }

Loading…
Cancel
Save