Merge pull request #10 from vale981/total_time

display total time worked, braked and tracked
This commit is contained in:
Pavel Korytov 2023-06-02 23:45:40 +03:00 committed by GitHub
commit d05d9cb333
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -248,14 +248,15 @@ return it, otherwise, return a value like a calc error."
('nil 0)))
0))
(defun pomm-third-time--worked-time ()
"Get total time worked in the current iteration."
(let ((iteration (alist-get 'iteration
(defun pomm-third-time--total-time (&optional kind)
"Get total time spent in `state` in the current iteration."
(let* ((kind (if kind kind 'work))
(iteration (alist-get 'iteration
(alist-get 'current pomm-third-time--state)))
(current-kind (alist-get 'kind (alist-get 'current pomm-third-time--state))))
(apply
#'+
(if (eq current-kind 'work)
(if (eq current-kind kind)
(pomm-third-time--current-period-time)
0)
(mapcar
@ -265,9 +266,10 @@ return it, otherwise, return a value like a calc error."
(seq-filter
(lambda (item)
(and (= (alist-get 'iteration item) iteration)
(eq (alist-get 'kind item) 'work)))
(eq (alist-get 'kind item) kind)))
(alist-get 'history pomm-third-time--state))))))
(defun pomm-third-time--need-switch-p ()
"Check if the break period has to end."
(and
@ -536,7 +538,9 @@ KIND is the same as in `pomm-third-time--state'"
(iteration (alist-get 'iteration
(alist-get 'current pomm-third-time--state)))
(break-time (pomm-third-time--break-time))
(period-time (pomm-third-time--current-period-time)))
(period-time (pomm-third-time--current-period-time))
(total-work (pomm-third-time--total-time 'work))
(total-break (pomm-third-time--total-time 'break)))
(concat
(format "Iteration #%d. " iteration)
"State: "
@ -556,9 +560,17 @@ KIND is the same as in `pomm-third-time--state'"
(propertize
(pomm-third-time--format-period break-time)
'face 'success)
". Total time worked: "
".\nTotal time worked: "
(propertize
(pomm-third-time--format-period (pomm-third-time--worked-time))
(pomm-third-time--format-period total-work)
'face 'success)
". Total time braked: "
(propertize
(pomm-third-time--format-period total-break)
'face 'success)
". Total time tracked: "
(propertize
(pomm-third-time--format-period (+ total-work total-break))
'face 'success))))))
(defclass pomm-third-time--transient-history (transient-suffix)