Overdue Tasks woes

Hey-oh!

Been trying to create a advanced query to display my overdue tasks, but for some reason its grabbing tasks that are not scheduled and all tasks that have a due date but haven’t been completed no matter if its a due yesterday, today or a week in the future :thinking:

I’ve searched the forums and watched a bunch of youtube videos, but none of the methods seem to work and there seems to have been a change in the syntax used at some point which also makes it a bit difficult to understand what does and doesn’t work anymore.

I have tried the one referenced in the docs, but no luck either…

# 🔴 Overdue Tasks   {{renderer :todomaster}}
*Not Working Yet...*
#+BEGIN_QUERY
 {
 :query [:find (pull ?b [*])
          :in $ ?start ?today
          :where
          (task ?b #{"NOW" "LATER" "TODO" "DOING"})
          (between ?b ?start ?today)]
:inputs [:-56d :today]
:breadcrumb-show? false
:group-by-page? false
:collapsed? false
:table-view? false
}
#+END_QUERY

I’ve also played with doing it this way with no luck…

# 🔴 Overdue Tasks   {{renderer :todomaster}}
*Not Working Yet...*
#+BEGIN_QUERY
{
:query [:find (pull ?b [*])
      :in $ ?yesterday
      :where
        [?b :block/marker ?m]
        [(contains? #{"TODO" "DOING" "WAITING" "NOW" "WAIT" "LATER"} ?m)]
        (or-join [?b ?p]
          [?b :block/page ?p]
          (and
            [?e :block/refs ?b]
            [?e :block/page ?p]
          )
        )
        [?p :block/journal-day ?d]
        [(<= ?d ?yesterday)]]
:inputs [:yesterday]
:result-transform (fn [result]
  (sort-by (fn [h]
        (get h :block/marker))
        result))
:breadcrumb-show? false
:group-by-page? false
:collapsed? false
:table-view? false
}
#+END_QUERY

Any help or ideas would be greatly appreciated! TYIA!

Please share with us some example blocks that should be grabbed and some that should not, so as we come with a working query.

Here is mine, and it seems to work

#+BEGIN_QUERY
   {:title [:h2 "🔥 MISSED"]
    :query [:find (pull ?b [*])
            :in $ ?day
            :where
            (task ?b #{"TODO" "LATER", "WAIT", "CANCELLED"})
            [?b :block/deadline ?ded]
            [(< ?ded ?day)]]
    :inputs [:today]
    :result-transform (fn [result]
                        (sort-by (fn [h]
                                   (get h :block/priority "Z")) result))
    :group-by-page? false
    :collapsed? false}
#+END_QUERY

Tried this, after correcting some syntax errors I still get no results :person_shrugging:

# 🔴 Overdue Tasks   {{renderer :todomaster}}
*Not Working Yet...*
#+BEGIN_QUERY
   {
    :query [:find (pull ?b [*])
            :in $ ?day
            :where
            (task ?b #{"TODO" "LATER" "WAITING" "DOING"})
            [?b :block/deadline ?ded]
            [(< ?ded ?day)]]
    :inputs [:today]
    :result-transform (fn [result]
                        (sort-by (fn [h]
                                   (get h :block/priority "Z")) result))
    :group-by-page? false
    :collapsed? false
}
#+END_QUERY

Hey again, mentaloid :wave:

Similar to my other post your helping with…

Certainly!

They are all Tasks which would reside on the daily Journal pages or directly on the customer page where this query is located. All tasks may be referenced by a parent block as well.

Sample Journal page

## Scratchpad
	-
	-
- ## Meetings
	- [[Customer B]] - Setup & Configure #SSO/EntraID #meeting
		- **Participants:** 
		- **Topics:**
			- Introductions / Agenda
			- #AzureBlob - Follow-up from last week?
				- How has the mount and automation with Partner A been working?
				- 3 other partners on Files.com currently
			- #SSO / #EntraID
				- SCIM
			- Next Steps
		- **Blockers:**
			-
		- **Decisions:**
			-
		- **Action Items:**
			- TODO [#A] Update [[Customer C]] on renewal discussions
		- **Notes:**
			- [files.com/Azure SSO via SAML](https://www.files.com/docs/user-accounts/sso-single-sign-on/azure-ad-sso#azure-sso-via-saml)
			- ==Reminder:== Need break glass account
			-
	- Check-in w/ [[EL]]
	  collapsed:: true
		-
- ## Tasks
	- DONE [#B] Call [[Customer A]] at [[Organization A]] to introduce myself as their SA #call
	  collapsed:: true
	  SCHEDULED: <2024-08-19 Mon>
		- No answer, left vmail
		- Sent follow-up email 
	- DONE [#B] Call [[Customer B]] at [[Organization A]] to introduce myself as their SA #call
	  collapsed:: true
	  SCHEDULED: <2024-08-19 Mon>
		- Customer answered
		- Would like to understand more about the product
		- Only concerns have been previously with SmartFile
			- Slowness
			- Disconnects
		- Looking forward to meeting!
		- Sent follow-up email with link to schedule meeting
	- DONE [#A] Prep for meeting w/ [[Customer C]] at [[Organization B]] today at 1pm
	  SCHEDULED: <2024-08-19 Mon>
	  :LOGBOOK:
	  CLOCK: [2024-08-19 Mon 09:49:43]--[2024-08-19 Mon 10:04:14] =>  00:14:31
	  :END:
	- DONE [#C] Professional Development - [Datalog - Parameterized queries](https://www.learndatalogtoday.org/chapter/3)
	  SCHEDULED: <2024-08-19 Mon>
	  :LOGBOOK:
	  CLOCK: [2024-08-19 Mon 09:49:36]--[2024-08-19 Mon 09:49:42] =>  00:00:06
	  CLOCK: [2024-08-19 Mon 10:04:27]--[2024-08-19 Mon 11:41:13] =>  01:36:46
	  :END:
	- TODO [#C] Professional Development - [Datalog - More Queries](https://www.learndatalogtoday.org/chapter/4)

Sample Customer Page

icon:: 🏢
tags:: Customers, myCustomers
alias:: ACME

- **Links**
  [CRM](xxxxx)          [+CustomerSuccess](xxxxx)          [Website](https://files.com/)           [LinkedIn](https://www.linkedin.com/company/xxxxx)
- **Business Use Case**
  *...*
- **Partners & Technologies**
  #EntraID #AzureBlob
- ### 🔎 Account Maintenance
	- Migrated from SmartFile on [[2024-07-29]]
	-
- ### 🎉 Increased Usage Wins
	- ...
- ### 🎯 Customer Opportunities
	- [[ACME/Azure SSO]] {{renderer :todomaster}}
		- TODO Using SCIM?
		- TODO Discuss User/Group Management
			- TODO Are User Groups ready in Entra ID?
			- TODO Have we replicated them in Files.com?
		- TODO Do we have a break-glass user account?
		- TODO Configure Entra ID SSO Integration
		- TODO Validate Configuration
	- [[ACME/Email Inboxes]] {{renderer :todomaster}}
	  collapsed:: true
		- TODO Additional Discovery Needed
		  id:: 66bf9ef1-9c6b-416d-a36d-c8b80333ae7a
		  *Currently SMB customers are emailing CSV's to Account Directors whom forward it to the Data Team to manually upload into the Data Lake.*
	- ✅ **DONE**
	  collapsed:: true
		- [[ACME/Azure Blob]] {{renderer :todomaster}}
		  collapsed:: true
			- DONE Determine Permissions Required for Azure Blob
			- DONE Create Azure Blob as Remote Server & Validate
			- DONE Determine & Create Mount for Azure Blob
			- DONE Create Permissions Fence
			- DONE Create Automation for ==Partner A==
- ### 💡 Feature Requests
	-
- ### 🐞 Issue Tracking
	-
- ### 🚀 Related Tasks
  #+BEGIN_QUERY
  {
  :query (and [[ACME Corporation]] (task NOW LATER DOING TODO WAITING))
  :breadcrumb-show? true
  :collapsed? false
  :table-view? false
  :group-by-page? true
  }
  #+END_QUERY
- ### 🪬 Identified Features
  #+BEGIN_QUERY
  {
     :query [:find ?name
     :in $ ?current-name %
     :where
       [?current :block/name ?current-name]
       [?meeting :block/name "meeting"]
       [?root :block/refs ?current]
       [?root :block/refs ?meeting]
       (ancestor ?root ?b)
       [?b :block/refs ?ref]
       [?ref :block/properties ?props]
       [(get ?props :type) ?type]
       [(= ?type "feature")]
       [?ref :block/original-name ?name]
   ]
   :inputs [:current-page
     [
       [
         [ancestor ?a ?b]
         [?b :block/parent ?a]
       ]
       [
         [ancestor ?a ?b]
         [?parent :block/parent ?a]
         (ancestor ?parent ?b)
       ]
     ]
   ]
  }
  #+END_QUERY
- ### Notes
	- ...

As far as references, I always “tag/reference” the customer organization page either in the same block as the TODO or in a parent block in the case of a meeting logged on the Journal page. TODO’s on the Customer page directly are usually part of a active or upcoming project/opportunity.

Customer pages are normal pages, no special type:: configured. People however have a page type:: person and each “person page” is also linked to their Organization via the Organization:: [[ACME Corporation]] custom property.

Whats different?

  • This query is hosted on a page called [[Tasks]] and should only return Tasks (TODO, DOING, LATER, WAITING) that are SCHEDULED AND the date has PASSED.

Below is a copy of my [[Tasks]] page as well for reference.

icon:: 🚀

- # 🟢 Active Tasks   {{renderer :todomaster}}
  #+BEGIN_QUERY
  {
  :query (and (task DOING NOW) (not [[Templates]]) (not "type:: opportunity"))
  :result-transform (fn [result]
                                   (sort-by (fn [h]
                                                    (get h :block/priority "Z")) result))
  :table-view? false
  :breadcrumb-show? false
  :collapsed? false
  }
  #+END_QUERY
- # 🔴 Overdue Tasks   {{renderer :todomaster}}
  *Not Working Yet...*
  #+BEGIN_QUERY
     {
      :query [:find (pull ?b [*])
              :in $ ?day
              :where
              (task ?b #{"TODO" "LATER" "WAITING" "DOING"})
              [?b :block/deadline ?ded]
              [(< ?ded ?day)]]
      :inputs [:today]
      :result-transform (fn [result]
                          (sort-by (fn [h]
                                     (get h :block/priority "Z")) result))
      :group-by-page? false
      :collapsed? false
  }
  #+END_QUERY
- # 🤔 Fleeting Tasks   {{renderer :todomaster}}
  #+BEGIN_QUERY
  {
  :query (and (task TODO LATER) (not [[Templates]]) (not "SCHEDULED") (not (property :type "opportunity") (property :tags "Customers")))
  :result-transform (fn [result]
                                   (sort-by (fn [h]
                                                    (get h :block/priority "Z")) result))
  :table-view? false
  :breadcrumb-show? true
  :collapsed? false
  }
  #+END_QUERY

Thank you, again!

Both between and journal-day refer to journal dates, not to scheduled date.

  • But your tasks are not in the journal, they are in page [[Tasks]]
  • Should rather use :block/deadline or :block/scheduled or both.

Which version of Logseq do you use? Mine is 0.10.9 and the syntax is totally valid there. Maybe todomaster is doing something weird here? (I don’t have it installed)

Since you use SCHEDULED instead of the DEADLINE, the gist of the query should be something like

#+BEGIN_QUERY
{:query [:find (pull ?b [*])
             :in $ ?day
             :where
             (task ?b #{"TODO" "LATER", "WAIT", "CANCELLED"})
             [?b :block/scheduled ?shd]
             [(< ?shd ?day)]]
:inputs [:today]
:group-by-page? true}
#+END_QUERY

I’ve just tested the query above on your scratchpad example and it indeed returns the expected results (tasks that are not DONE and scheduled in the past).

Thanks!

I mistakenly assumed :block/deadline was the same as :block/scheduled and I don’t use deadline. My tasks are on my journal pages, so once I changed that it worked, beautifully.

Thank you, again!