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
Signed by: dbo
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':
Start date for the workload report. When not provided, will 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'. understood by `org-read-date'.
`:end-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 `org-ql' expression (in sexp syntax) to filter the list of
tasks to consider. Defaults to (todo)." tasks to consider. Defaults to (todo)."
(let* ((start-date (or (plist-get params :start-date) (let* ((start-date (or (plist-get params :start-date)
(org-read-date nil nil "."))) nil))
(end-date (or (plist-get params :end-date) (end-date (or (plist-get params :end-date)
(user-error "No end-date provided"))) (user-error "No end-date provided")))
(increment (or (plist-get params :increment) (increment (or (plist-get params :increment)
"+1d")) "+1d"))
(org-ql-match (or (plist-get params :org-ql-match) (org-ql-match (or (plist-get params :org-ql-match)
'(todo))) '(todo)))
(current start-date) (current (or start-date
(org-read-date nil nil ".")))
(date-range nil)) (date-range nil))
;; Check input ;; Check input
(unless (string-match-p (org-re-timestamp 'inactive) (unless (or (null start-date)
(format "[%s]" start-date)) (string-match-p (org-re-timestamp 'inactive)
(format "[%s]" start-date)))
(user-error "Invalid start date given: %s" start-date)) (user-error "Invalid start date given: %s" start-date))
(unless (string-match-p (org-re-timestamp 'inactive) (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 ;; this might be slow, try to reduce the calls to
;; `db/org-planned-tasks-in-range'. ;; `db/org-planned-tasks-in-range'.
(insert "| Until | Planned Total |\n| <r> | <r> |\n|---|\n") (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 (let ((total-time (car (db/org-planned-tasks-in-range start-date
interval-end-date interval-end-date
org-ql-match)))) org-ql-match))))