mirror of https://github.com/tasks/tasks
Merge tag '7.3.2'
commit
769a23dd29
@ -1,28 +0,0 @@
|
||||
<component name="InspectionProjectProfileManager">
|
||||
<profile version="1.0">
|
||||
<option name="myName" value="Project Default" />
|
||||
<inspection_tool class="ControlFlowStatementWithoutBraces" enabled="true" level="WARNING" enabled_by_default="true" />
|
||||
<inspection_tool class="Convert2streamapi" enabled="false" level="WEAK WARNING" enabled_by_default="false" />
|
||||
<inspection_tool class="DoubleBraceInitialization" enabled="true" level="WARNING" enabled_by_default="true" />
|
||||
<inspection_tool class="EqualsReplaceableByObjectsCall" enabled="false" level="WEAK WARNING" enabled_by_default="false" />
|
||||
<inspection_tool class="Finalize" enabled="true" level="WARNING" enabled_by_default="true">
|
||||
<option name="ignoreTrivialFinalizers" value="true" />
|
||||
</inspection_tool>
|
||||
<inspection_tool class="Guava" enabled="false" level="WARNING" enabled_by_default="false" />
|
||||
<inspection_tool class="MissingOverrideAnnotation" enabled="true" level="WARNING" enabled_by_default="true">
|
||||
<option name="ignoreObjectMethods" value="true" />
|
||||
<option name="ignoreAnonymousClassMethods" value="false" />
|
||||
</inspection_tool>
|
||||
<inspection_tool class="OverridableMethodCallDuringObjectConstruction" enabled="true" level="WARNING" enabled_by_default="true" />
|
||||
<inspection_tool class="SpellCheckingInspection" enabled="false" level="TYPO" enabled_by_default="false">
|
||||
<option name="processCode" value="true" />
|
||||
<option name="processLiterals" value="true" />
|
||||
<option name="processComments" value="true" />
|
||||
</inspection_tool>
|
||||
<inspection_tool class="StaticPseudoFunctionalStyleMethod" enabled="false" level="WARNING" enabled_by_default="false" />
|
||||
<inspection_tool class="SuspiciousIndentAfterControlStatement" enabled="true" level="WARNING" enabled_by_default="true" />
|
||||
<inspection_tool class="TryFinallyCanBeTryWithResources" enabled="false" level="WARNING" enabled_by_default="false" />
|
||||
<inspection_tool class="TryWithIdenticalCatches" enabled="false" level="WARNING" enabled_by_default="false" />
|
||||
<inspection_tool class="UnnecessarySuperQualifier" enabled="true" level="WARNING" enabled_by_default="true" />
|
||||
</profile>
|
||||
</component>
|
||||
@ -0,0 +1,42 @@
|
||||
package org.tasks.db;
|
||||
|
||||
import static org.junit.Assert.assertEquals;
|
||||
import static org.tasks.db.QueryUtils.showCompleted;
|
||||
import static org.tasks.db.QueryUtils.showHidden;
|
||||
|
||||
import androidx.test.ext.junit.runners.AndroidJUnit4;
|
||||
import com.todoroo.andlib.sql.Functions;
|
||||
import com.todoroo.astrid.data.Task;
|
||||
import org.junit.Test;
|
||||
import org.junit.runner.RunWith;
|
||||
|
||||
@RunWith(AndroidJUnit4.class)
|
||||
public class QueryUtilsTest {
|
||||
@Test
|
||||
public void replaceHiddenLT() {
|
||||
assertEquals(
|
||||
"(1)",
|
||||
showHidden(Task.HIDE_UNTIL.lt(Functions.now()).toString()));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void replaceHiddenLTE() {
|
||||
assertEquals(
|
||||
"(1)",
|
||||
showHidden(Task.HIDE_UNTIL.lte(Functions.now()).toString()));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void replaceUncompletedEQ() {
|
||||
assertEquals(
|
||||
"(1)",
|
||||
showCompleted(Task.COMPLETION_DATE.eq(0).toString()));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void replaceUncompletedLTE() {
|
||||
assertEquals(
|
||||
"(1)",
|
||||
showCompleted(Task.COMPLETION_DATE.lte(0).toString()));
|
||||
}
|
||||
}
|
||||
@ -0,0 +1,36 @@
|
||||
package org.tasks.db;
|
||||
|
||||
import com.todoroo.andlib.sql.Criterion;
|
||||
import com.todoroo.andlib.utility.DateUtilities;
|
||||
import com.todoroo.astrid.data.Task;
|
||||
import java.util.regex.Pattern;
|
||||
|
||||
public class QueryUtils {
|
||||
|
||||
private static final Pattern HIDDEN =
|
||||
Pattern.compile("tasks\\.hideUntil<=?\\(strftime\\('%s','now'\\)\\*1000\\)");
|
||||
|
||||
private static final Pattern UNCOMPLETED = Pattern.compile("tasks\\.completed<?=0");
|
||||
|
||||
public static String showHidden(String query) {
|
||||
return HIDDEN.matcher(query).replaceAll("1");
|
||||
}
|
||||
|
||||
public static String showCompleted(String query) {
|
||||
return UNCOMPLETED.matcher(query).replaceAll("1");
|
||||
}
|
||||
|
||||
public static String showHiddenAndCompleted(String query) {
|
||||
return showCompleted(showHidden(query));
|
||||
}
|
||||
|
||||
public static String showRecentlyCompleted(String query) {
|
||||
return UNCOMPLETED
|
||||
.matcher(query)
|
||||
.replaceAll(
|
||||
Criterion.or(
|
||||
Task.COMPLETION_DATE.lte(0),
|
||||
Task.COMPLETION_DATE.gte(DateUtilities.now() - 59999))
|
||||
.toString());
|
||||
}
|
||||
}
|
||||
Loading…
Reference in New Issue