Tag based task aggregator

  • Should rather use a separate query for the special case of the remaining tasks.
  • If you insist on mixing them, try something like this:
    #+BEGIN_QUERY
    ; see https://discuss.logseq.com/t/tag-based-task-aggregator/21378/2
    {:title "tasks related to current page"
     :query [:find (pull ?b [*])
       :in $ ?inputpage
       :where
         [task ?b #{"NOW" "LATER" "DOING" "TODO"}]
         [(set ["work" "home" "shopping"]) ?categories]
         (or-join [?b ?inputpage ?categories]
           (and
             [(contains? ?categories ?inputpage)]
             [?p :block/name ?inputpage]
             (or-join [?p ?b]
               [?b :block/path-refs ?p]
               (and
                 [?page :block/tags ?p]
                 [?b :block/path-refs ?page]
               )
             )
           )
           (and
             (not [(contains? ?categories ?inputpage)])
             (not
               [?p :block/name ?pagename]
               [(contains? ?categories ?pagename)]
               (or-join [?p ?b]
                 [?b :block/path-refs ?p]
                 (and
                   [?page :block/tags ?p]
                   [?b :block/path-refs ?page]
                 )
               )
             )
           )
         )
     ]
     :result-transform (fn [result] (sort-by (fn [r] (get r :block/content)) result))
     :group-by-page? false
     :breadcrumb-show? false
     :inputs ["work"]
    }
    #+END_QUERY
    
    • For the special case, should still pass an input, just one not found in the list.
      • e.g. :inputs [""]
1 Like