Allow no start date in workload overview report

This is different from the previous default start date of today, as now all past
items will also be considered.  Additionally, also include the start date (or
today, if not given) to be included in the result table to show all efforts
still left for that day.
This commit is contained in:
Daniel - 2022-10-07 15:42:02 +02:00
parent e1123a8205
commit 047627c6ac
No known key found for this signature in database
GPG Key ID: 784AA8DF0CCDF625
1 changed files with 8 additions and 6 deletions

View File

@ -534,7 +534,7 @@ PARAMS is a property list of the following parameters:
`:start-date':
Start date for the workload report. When not provided, will
default to today. When provided, must be in a format
default to no start date. When provided, must be in a format
understood by `org-read-date'.
`:end-date':
@ -554,19 +554,21 @@ PARAMS is a property list of the following parameters:
`org-ql' expression (in sexp syntax) to filter the list of
tasks to consider. Defaults to (todo)."
(let* ((start-date (or (plist-get params :start-date)
(org-read-date nil nil ".")))
nil))
(end-date (or (plist-get params :end-date)
(user-error "No end-date provided")))
(increment (or (plist-get params :increment)
"+1d"))
(org-ql-match (or (plist-get params :org-ql-match)
'(todo)))
(current start-date)
(current (or start-date
(org-read-date nil nil ".")))
(date-range nil))
;; Check input
(unless (string-match-p (org-re-timestamp 'inactive)
(format "[%s]" start-date))
(unless (or (null start-date)
(string-match-p (org-re-timestamp 'inactive)
(format "[%s]" start-date)))
(user-error "Invalid start date given: %s" start-date))
(unless (string-match-p (org-re-timestamp 'inactive)
@ -597,7 +599,7 @@ PARAMS is a property list of the following parameters:
;; this might be slow, try to reduce the calls to
;; `db/org-planned-tasks-in-range'.
(insert "| Until | Planned Total |\n| <r> | <r> |\n|---|\n")
(dolist (interval-end-date (cdr date-range)) ; `cdr' is for ignoring the `start-date' itself
(dolist (interval-end-date date-range)
(let ((total-time (car (db/org-planned-tasks-in-range start-date
interval-end-date
org-ql-match))))