@ -35,11 +35,6 @@ internal object TaskListQueryRecursive {
. join ( Join . inner ( RECURSIVE , GoogleTask . PARENT . eq ( RECURSIVE _TASK ) ) )
. join ( Join . inner ( GoogleTask . TABLE , Criterion . and ( GoogleTask . TASK . eq ( Task . ID ) , GoogleTask . DELETED . eq ( 0 ) ) ) )
. where ( activeAndVisible ( ) )
private val CALDAV _SUBTASKS =
QueryTemplate ( )
. join ( Join . inner ( RECURSIVE , Task . PARENT . eq ( RECURSIVE _TASK ) ) )
. join ( Join . inner ( CaldavTask . TABLE , Criterion . and ( CaldavTask . TASK . eq ( Task . ID ) , CaldavTask . DELETED . eq ( 0 ) ) ) )
. where ( activeAndVisible ( ) )
private val GOOGLE _AND _CALDAV _SUBTASKS =
QueryTemplate ( )
. join ( Join . inner ( RECURSIVE , Criterion . or ( GoogleTask . PARENT . eq ( RECURSIVE _TASK ) , Task . PARENT . eq ( RECURSIVE _TASK ) ) ) )
@ -55,7 +50,10 @@ internal object TaskListQueryRecursive {
when ( filter ) {
is CaldavFilter -> {
parentQuery = newCaldavQuery ( filter )
subtaskQuery = CALDAV _SUBTASKS
subtaskQuery = QueryTemplate ( )
. join ( Join . inner ( RECURSIVE , Task . PARENT . eq ( RECURSIVE _TASK ) ) )
. join ( Join . inner ( CaldavTask . TABLE , Criterion . and ( CaldavTask . TASK . eq ( Task . ID ) , CaldavTask . DELETED . eq ( 0 ) ) ) )
. where ( activeAndVisible ( ) )
}
is GtasksFilter -> {
parentQuery = newGoogleTaskQuery ( filter )
@ -66,7 +64,9 @@ internal object TaskListQueryRecursive {
subtaskQuery = when {
subtasks . hasGoogleSubtasks && subtasks . hasSubtasks -> GOOGLE _AND _CALDAV _SUBTASKS
subtasks . hasGoogleSubtasks -> GOOGLE _SUBTASKS
else -> CALDAV _SUBTASKS
else -> QueryTemplate ( )
. join ( Join . inner ( RECURSIVE , Task . PARENT . eq ( RECURSIVE _TASK ) ) )
. where ( activeAndVisible ( ) )
}
joinedQuery += " LEFT JOIN (SELECT task, max(indent) AS max_indent FROM recursive_tasks GROUP BY task) AS recursive_indents ON recursive_indents.task = tasks._id "
where += " AND indent = max_indent "