ADD tests for overloaded days
This commit is contained in:
parent
e3beacfbde
commit
7f1426ee2b
|
@ -1350,7 +1350,7 @@ Each member in the cons cell is a timestamp-plist."
|
|||
;; unless specified manually
|
||||
(-let* ((tz (current-time-zone))
|
||||
(start-time* (if (org-ml-time-is-long start-time) start-time
|
||||
`(,@start-time 0 0)))
|
||||
`(,@(-take 3 start-time) 0 0)))
|
||||
((y m d H M) start-time*)
|
||||
(start-epoch (encode-float-time `(0 ,M ,H ,d ,m ,y nil nil ,tz)))
|
||||
(end-epoch (+ start-epoch range))
|
||||
|
@ -1391,14 +1391,14 @@ Each member in the cons cell is a timestamp-plist."
|
|||
"Return t if total time of timestamp-plists in TSPS exceeds 24 hours.
|
||||
It is assumed the TSPS represents tasks and appointments within one
|
||||
day."
|
||||
(<= 86400 (-sum (--map (plist-get tsp :range) tsps))))
|
||||
(<= 86400 (-sum (--map (plist-get it :range) tsps))))
|
||||
|
||||
(defun org-x-cluster-get-overloads ()
|
||||
(defun org-x-cluster-get-overloads* (tsps)
|
||||
"Return list of lists of timestamp-plists grouped by day.
|
||||
Anything present represents all the tasks in a single day if that day
|
||||
is overloaded. If a day is not overloaded there will be nothing for it
|
||||
in the returned list."
|
||||
(->> (org-x-cluster-get-unprocessed)
|
||||
(->> tsps
|
||||
(--filter (< 0 (plist-get it :range)))
|
||||
(-mapcat #'org-x-cluster-split-tsp-maybe)
|
||||
(org-x-cluster-append-unixtime)
|
||||
|
@ -1407,6 +1407,14 @@ in the returned list."
|
|||
(org-x-cluster-daily-split)
|
||||
(--filter (org-x-cluster-overloaded-p it))))
|
||||
|
||||
(defun org-x-cluster-get-overloads ()
|
||||
"Return list of lists of timestamp-plists grouped by day.
|
||||
Anything present represents all the tasks in a single day if that day
|
||||
is overloaded. If a day is not overloaded there will be nothing for it
|
||||
in the returned list."
|
||||
(->> (org-x-cluster-get-unprocessed)
|
||||
(org-x-cluster-get-overloads*)))
|
||||
|
||||
;; conflict/overload frontend
|
||||
|
||||
;; I could just fetch the org headings and throw them into a new buffer. But
|
||||
|
|
|
@ -516,6 +516,88 @@ Forms are denoted like %(FORM)%."
|
|||
((:start-time (2022 1 1 12 5) :range 900 :offset 79 :filepath "fp")
|
||||
(:start-time (2022 1 1 12 10) :range 900 :offset 157 :filepath "fp"))))
|
||||
|
||||
(org-x--test-buffer-strings "Overloads"
|
||||
(->> (org-x-cluster-extract-buffer "fp")
|
||||
(org-x-cluster-get-overloads*)
|
||||
;; drop the :unixtime key from the front to make testing easier
|
||||
(--map (--map (-drop 2 it) it)))
|
||||
|
||||
;; this assumes the TODO vs active ts parsing works as expected
|
||||
"no timestamps"
|
||||
("* TODO one"
|
||||
"* TODO two")
|
||||
=> nil
|
||||
|
||||
"not overloaded"
|
||||
("* TODO one"
|
||||
"SCHEDULED: [2022-01-01 Tue 00:00]"
|
||||
":PROPERTIES:"
|
||||
":Effort: 0:15"
|
||||
":END:"
|
||||
"* TODO two"
|
||||
"SCHEDULED: [2022-01-01 Tue 00:00]"
|
||||
":PROPERTIES:"
|
||||
":Effort: 0:15"
|
||||
":END:")
|
||||
=> nil
|
||||
|
||||
"overloaded (exactly 24 hours)"
|
||||
("* TODO one"
|
||||
"SCHEDULED: [2022-01-01 Tue 00:00]"
|
||||
":PROPERTIES:"
|
||||
":Effort: 12h"
|
||||
":END:"
|
||||
"* TODO two"
|
||||
"SCHEDULED: [2022-01-01 Tue 00:00]"
|
||||
":PROPERTIES:"
|
||||
":Effort: 12h"
|
||||
":END:")
|
||||
=> '(((:start-time (2022 1 1 0 0) :range 43200 :offset 1 :filepath "fp")
|
||||
(:start-time (2022 1 1 0 0) :range 43200 :offset 78 :filepath "fp")))
|
||||
|
||||
"overloaded (over 24 hours)"
|
||||
("* TODO one"
|
||||
"SCHEDULED: [2022-01-01 Tue 00:00]"
|
||||
":PROPERTIES:"
|
||||
":Effort: 12h"
|
||||
":END:"
|
||||
"* TODO two"
|
||||
"SCHEDULED: [2022-01-01 Tue 00:00]"
|
||||
":PROPERTIES:"
|
||||
":Effort: 13h"
|
||||
":END:")
|
||||
=> '(((:start-time (2022 1 1 0 0) :range 43200 :offset 1 :filepath "fp")
|
||||
(:start-time (2022 1 1 0 0) :range 46800 :offset 78 :filepath "fp")))
|
||||
|
||||
"overloaded (over 24 hours and split)"
|
||||
("* TODO one"
|
||||
"SCHEDULED: [2022-01-01 Tue 00:00]"
|
||||
":PROPERTIES:"
|
||||
":Effort: 12h"
|
||||
":END:"
|
||||
"* TODO two"
|
||||
"SCHEDULED: [2022-01-01 Tue 00:00]"
|
||||
":PROPERTIES:"
|
||||
":Effort: 25h"
|
||||
":END:")
|
||||
=> '(((:start-time (2022 1 1 0 0) :range 43200 :offset 1 :filepath "fp")
|
||||
(:start-time (2022 1 1 0 0) :range 86400 :offset 78 :filepath "fp")))
|
||||
|
||||
"overloaded (over 48 hours)"
|
||||
("* TODO one"
|
||||
"SCHEDULED: [2022-01-01 Tue 00:00]"
|
||||
":PROPERTIES:"
|
||||
":Effort: 12h"
|
||||
":END:"
|
||||
"* TODO two"
|
||||
"SCHEDULED: [2022-01-01 Tue 12:00]"
|
||||
":PROPERTIES:"
|
||||
":Effort: 36h"
|
||||
":END:")
|
||||
=> '(((:start-time (2022 1 1 0 0) :range 43200 :offset 1 :filepath "fp")
|
||||
(:start-time (2022 1 1 12 0) :range 43200 :offset 78 :filepath "fp"))
|
||||
((:start-time (2022 1 2 0 0) :range 86400 :offset 78 :filepath "fp"))))
|
||||
|
||||
(defmacro org-x--test-time-splitter-specs (&rest specs)
|
||||
(declare (indent 0))
|
||||
;; 3 args for clarity, currently does nothing functional
|
||||
|
|
Loading…
Reference in New Issue