diff options
author | Thanos Apollo <[email protected]> | 2024-07-23 17:45:20 +0300 |
---|---|---|
committer | Thanos Apollo <[email protected]> | 2024-07-23 18:36:14 +0300 |
commit | a6d7ef539ae3a289ab83c61cba5d1ff7c307b928 (patch) | |
tree | 9cbc7cf6c518a3f61714a2a1846503535a677756 /gnosis-dashboard.el | |
parent | feb8a4496b93b412c9f3d6197499127cdbc945fe (diff) |
New function: dashboard-year-stats.
* Return YEAR review stats.
Diffstat (limited to 'gnosis-dashboard.el')
-rw-r--r-- | gnosis-dashboard.el | 31 |
1 files changed, 31 insertions, 0 deletions
diff --git a/gnosis-dashboard.el b/gnosis-dashboard.el index c2279c2..5089fd5 100644 --- a/gnosis-dashboard.el +++ b/gnosis-dashboard.el @@ -67,6 +67,37 @@ (push (list current-year (+ month 1) (+ day 1)) result)))) (nreverse result))) +(defun gnosis-dashboard-year-stats (&optional year) + "Return YEAR review stats." + (let ((notes nil)) + (cl-loop for date in (gnosis-dashboard-generate-dates (and year)) + do (setq notes (append notes (list (gnosis-get-date-total-notes date))))) + notes)) + +(defun gnosis-dashboard-month-reviews (month) + "Return reviewes for MONTH in current year." + (cl-assert (and (integerp month) + (< month 12)) + nil "Month must be an integer, lower than 12.") + (let* ((month-dates (cl-loop for date in (gnosis-dashboard-generate-dates) + if (and (= (nth 1 date) month) + (= (nth 0 date) (decoded-time-year (decode-time)))) + collect date)) + (month-reviews (cl-loop for date in month-dates + collect (gnosis-get-date-total-notes date)))) + month-reviews)) + +;; TODO: Optionally, add dates where no review was made. +(defun gnosis-dashboard-output-average-rev () + "Output the average daily notes reviewed for current year. + +Skips days where no note was reviewed." + (let ((total 0) + (entries (gnosis-dashboard-year-stats))) + (cl-loop for entry in entries + do (setq total (+ total entry))) + (/ total (length (remove 0 entries))))) + (defun gnosis-dashboard-output-note (id) "Output contents for note with ID, formatted for gnosis dashboard." (cl-loop for item in (append (gnosis-select '[main options answer tags type] 'notes `(= id ,id) t) |