Query for Tasks done today

Has anyone an idea for a query which shows me the tasks I finished on a specific day?
I would like to add this query to the journal queries to see what I achieved each day.

As of today, that is not yet possible. The database does not save a timestamp of the moment a task was finished. If you have logbook enabled, there will be org-mode style logs, but they are not (yet) indexed, so can not be queried.

In theory it is possible to write a regex parser and combine that with an advanced query to look for finished tasks, but so far nobody has taken that upon themselves.

So for now, you can only query for DONE tasks, not when that task was done

Thank you for your repsonse.
That would probably also answer the next question, if it is possible to list in the journal the task I was working on that day, by querying the logbook timestamps. But as they are not yet indexed, thatā€™s not possible.

What is possible to query, is the journal-day the task is in, so if the task is located in the correct day, then that information can be queried.

But, if a task is located in yesterdays journal, and you worked on, or finished it today, that cannot be queried (despite being in the logbook).

Is it possible now?
Would be great to have it.

1 Like

Please upvote

2 Likes

@John_Doe @sir79 If youā€™re still looking for a solution to this, try the PlugIn ā€˜Task Completionā€™ by Dmitri Dushkin. When checking a TODO as DONE it adds a completed property to the task with todays date. Completed tasks can then be searched by date - PlugIn includes a ā€˜completed tasks in previous weekā€™ query that can be simply modified to suit your individual criteria.

Hope that helps as workaround until this is standard Logseq functionality.

1 Like

Iā€™d like to use the ā€œTask Completionā€ plugin output with an Advanced Query, but canā€™t get it to work. If I comment out the (or ...), the following query returns all ā€œDONEā€ tasks which have a :completed property; but if I put it in, it returns nothing.

{:title [:h3 "Done today"]
 :query [:find (pull ?b [*])
   :in $ ?today
   :where
     [?b :block/marker "DONE"]
     [?b :block/properties ?properties]
     [(get ?properties :completed) ?completed]
     (or
       [(= ?completed ?today)]
       [(contains? ?completed ?today)]
     )
 ]
 :result-transform (fn [result] (sort-by 
     (fn [r] (get-in r [:block/properties :completed])
  ) result))  ; Sort by completion timestamp
 :inputs [:today]
 :table-view? false
 :group-by-page? false
 :breadcrumb-show? false
 :collapsed? false
}

If use task DONE with journals only

{
:title [:h3 "Today completed DONE task"]
:query (and (between today tomorrow) (task DONE) (property completed) )
	table-view? false
	:group-by-page? false
 	:breadcrumb-show? false
 	:collapsed? false
}

Thanks for the idea, @YU000jp, but Iā€™d like to be able to put tasks anywhere. Iā€™m sure there must be a way :slight_smile:

1 Like

Not directly what you were asking but maybe my query might help:

#+BEGIN_QUERY
{:title [:h2 "DONE"]
 :query [:find (pull ?h [*])
  :in $ ?page
  :where
   [?j :block/name ?page]
   [?j :block/journal-day ?day]
   [?h :block/marker ?marker]
   [(contains? #{"DONE"} ?marker)]
     [?h :block/refs ?j]
 ]
 :inputs [:query-page]
:table-view? false;
 :breadcrumb-show? false ;
 :collapsed? false;
 :result-transform (fn [result] (sort-by (fn [r] (get-in r [:block/scheduled])) result)) ; sort the result by the scheduled date
}
#+END_QUERY