Skip to content

Instantly share code, notes, and snippets.

@natecostello
Created April 25, 2023 15:14
Show Gist options
  • Save natecostello/b197526c4e58c69044a7be074d17ce28 to your computer and use it in GitHub Desktop.
Save natecostello/b197526c4e58c69044a7be074d17ce28 to your computer and use it in GitHub Desktop.
Logseq Journal Queries

These are Journal Queries displayed at the bottom of the current Journal Page

They are placed in this section of config.edn

:default-queries
 {:journals
 "INSERT HERE"
 }

Queries:

[{:title "🔨 NOW"
    :query [:find (pull ?h [*])
            :in $ ?start ?today
            :where
            [?h :block/marker ?marker]
            [(contains? #{"NOW" "DOING"} ?marker)]
            [?h :block/page ?p]
            [?p :block/journal? true]
            [?p :block/journal-day ?d]
            [(>= ?d ?start)]
            [(<= ?d ?today)]]
    :inputs [:14d :today]
    :result-transform (fn [result]
                        (sort-by (fn [h]
                                   (get h :block/priority "Z")) result))
    :collapsed? false}

   ;;Waiting Journal Query
   {:title "⏳️ WAITING"
    :query [:find (pull ?block [*])
            :where
            [?block :block/marker ?marker]
            [(contains? #{"WAITING"} ?marker)]]
    :collapsed? false
    :breadcrumb-show? false}

   ;;All next actions Journal Query
   {:title "All Next Actions"
    :query [:find (pull ?b [*])
            :where
            [?db_tag_page :block/name ?currpage]
            [?tagged-pages :block/tags ?db_tag_page]
            (or-join [?b ?tagged-pages]
                     [?b :block/refs ?tagged-pages]
                     (and [?tagged-pages :block/alias ?a]
                          [?b :block/refs ?a]))
            [?next :block/name "n"]
            [?b :block/refs ?next]
            (task ?b #{"TODO"})]
    :collapsed? true
    :breadcrumb-show? false}

   ;;Overdue Journal Query
   {:title "🔥 OVERDUE"
    :query [:find (pull ?block [*])
            :in $ ?start ?today
            :where
            [?block :block/marker ?marker]
            (or
             [?block :block/scheduled ?d]
             [?block :block/deadline ?d])
            [(>= ?d ?start)]
            [(<   ?d ?today)]

            [(contains? #{"NOW" "LATER" "TODO" "DOING" "WAITING"} ?marker)]]
    :inputs [:180d :today]
    :result-transform  (fn [result]
                         (sort-by  (fn [d]
                                     (get d :block/deadline)) result))
    :collapsed? false
    :breadcrumb-show? false}

   ;;Due tomorrow Journal Query
   {:title "👉️ TOMORROW"
    :query [:find (pull ?block [*])
            :in $ ?start ?next
            :where
            [?block :block/marker ?marker]

            (or
             [?block :block/scheduled ?d]
             [?block :block/deadline ?d])

            [(> ?d ?start)]
            [(<=   ?d ?next)]

            [(contains? #{"TODO" "DOING"} ?marker)]]
    :inputs [:today :+1d]
    :result-transform  (fn [result]
                         (sort-by  (fn [d]
                                     (get d :block/deadline)) result))
    :collapsed? true
    :breadcrumb-show? false}

   ;;Due in next seven days Jounal Query
   {:title "🔜 NEXT 7 DAYS"
    :query [:find (pull ?block [*])
            :in $ ?start ?next
            :where
            [?block :block/marker ?marker]

            (or
             [?block :block/scheduled ?d]
             [?block :block/deadline ?d])

            [(> ?d ?start)]
            [(<=   ?d ?next)]

            [(contains? #{"TODO" "DOING"} ?marker)]]
    :inputs [:+1d :+7d]
    :result-transform  (fn [result]
                         (sort-by  (fn [d]
                                     (get d :block/deadline)) result))
    :collapsed? true
    :breadcrumb-show? false}]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment