I’ve deleted all config queries for visual aid.
Make sure to paste the entire query from { till } and without the #+BEGIN_QUERY and #+END_QUERY between this part of the config:
Yes, part clarity, part personal preference.
The “shorthand” you suggest is actually an implementation of a simple query into an advanced query.
My opinion is to stick to either one and not combine them. It leads to confusion and user error from what I have seen.
In the backend it gets all converted to advanced query anyway.
As for your point about lists, please see the second query in the first post for how to do the same with advanced syntax.
Tasks that don’t reference a page regardless of nesting
This will exclude any tasks that are referencing a page or that one of the parent blocks references a page. This query uses rules for recursive searching.
To change this to reference instead of don’t reference, just remove the (not and closing ) around (check-ref ?p ?b)
#+BEGIN_QUERY
{:title "🔨 TODO"
:query [:find (pull ?b [*])
:in $ % ; % is used to pull in the rules below.
:where
[?b :block/marker ?marker]
[(contains? #{"TODO"} ?marker)]
;; Exclude pagename
[?p :block/name "pagename"]
(not (check-ref ?p ?b)) ; this calls the rules below.
]
:rules [ ; whenever two rules have the same name an or is applied. I'm not exactly sure how to explain it!
[(check-ref ?p ?b) ; definition of the rule, name and parameters.
[?b :block/refs ?p] ; rule content to be executed
]
[(check-ref ?p ?b)
[?b :block/parent ?t]
(check-ref ?p ?t) ; calling the rule again within this rule will make it recursive.
]
]
:breadcrumb-show? false
:collapsed? true
}
#+END_QUERY
Hi,
I added one of your queries (past deadline) and it worked.
Somehow, I am not sure why but the queries do not work anymore.
NOW works,
Past deadline does not
NEXT does not work either I believe
See the code here:
Blockquote
:default-queries
{:journals
[{: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}
{:title [:h3 “ Past scheduled”]
:query [:find (pull ?b [])
:in $ ?day ; ?day is the name for the first value in inputs further down.
:where
[?b :block/marker “TODO”] ; Using TODO straight in the clause because I want marker to be a specific value.
[?b :block/scheduled ?d] ; the block ?b has attribute scheduled with value ?d
[(< ?d ?day)] ; the value ?d is smaller than the value ?day
]
:inputs [:today] ; use the Logseq dynamic variable :today as input for this query (gives today’s date as yyyymmdd format)
:table-view? false}
{:title “ NEXT”
:query [:find (pull ?h [*])
:in $ ?start ?next
:where
[?h :block/marker ?marker]
[(contains? #{“NOW” “LATER” “TODO”} ?marker)]
[?h :block/page ?p]
[?p :block/journal? true]
[?p :block/journal-day ?d]
[(> ?d ?start)]
[(< ?d ?next)]]
:inputs [:today :7d-after]
:collapsed? false}]}
Could you help me out, please
(not sure why the indentation is not show once posted, when I insert the code in edit mode I see the indentation
For indentation to show you put the code between 3 backticks:
```
Like so.
```
To turn it into
Like so.
Anyway…
The query looks fine.
If you’re not getting a result, it could be an issue with the data.
What data do you have that you expect to be returned?
The past scheduled only shows TODO tasks with a scheduled date before today.
The Next shows only tasks on future journal dates. (Which is a really weird default query, considering journal pages are generated the day of and not in the future, but that is an aside.)
It is past scheduled and not past deadline
For things with a deadline in the past you have to replace the :block/scheduled with :block/deadline.
As for the not done part.
Change [?b :block/marker "TODO"] to (not [?b :block/marker "DONE"])
Or alternatively to
The next query doesn’t look at scheduled or deadline. It just looks at tasks in journal pages that are into the future. Which unless you make those yourself don’t even exist.
Ah! I see ! I have to admit I am still figuring out the task management.
So scheduled would be planned where deadline it needs to be done latest at that day right?
Actually I would even prefer to see both in that same query based on the date. So basically it would be a “Past date” or “overdue” regardless of scheduled or deadlines. Both need immediate review.
#+BEGIN_QUERY
{:title [:h3 "🔥 Tasks past due"]
:query [:find (pull ?b [*])
:in $ ?day
:where
[?b :block/marker ?m]
(not [(contains? #{"DONE" "CANCELED"} ?m)])
(or
[?b :block/scheduled ?d] ; Either the scheduled value
[?b :block/deadline ?d] ; or the deadline value
)
[(< ?d ?day)] ; the value is in the past
]
:inputs [:today]
:table-view? false
}
#+END_QUERY
figured out my own question. The default queries are:
NOW - Show me only tasks that are “NOW” or “DOING” that were created on a journal page with a date in the last two weeks.
NEXT - Show me only tasks that are “NOW” or “LATER” or “TODO” that were created on a journal page with a date in the next week. (makes no sense, as it does not look at DEADLINE or SCHEDULE, but at tasks in a future journal day)
Built in Scheduled & Deadline - Show me tasks which have a “scheduled” or “deadline” date of today.