summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorThanos Apollo <[email protected]>2024-07-23 18:46:49 +0300
committerThanos Apollo <[email protected]>2024-07-23 18:46:49 +0300
commite72d2dc67439d880d93739fe003d451c6c790ae3 (patch)
tree675c252e1873ae3f6c15f3d077bc1643881ed93d
parent293684279e55c14bb9a819a40ecfaddec5febe72 (diff)
[fix] get-date-total-notes creation of new entries.
* gnosis-get-date-total-notes should not create new entries unless it's for the current date.
-rw-r--r--gnosis.el11
1 files changed, 8 insertions, 3 deletions
diff --git a/gnosis.el b/gnosis.el
index 7f207f8..f9a224a 100644
--- a/gnosis.el
+++ b/gnosis.el
@@ -2033,13 +2033,18 @@ SUSPEND: Suspend note, 0 for unsuspend, 1 for suspend"
(defun gnosis-get-date-total-notes (&optional date)
"Return total notes reviewed for DATE.
+If entry for DATE does not exist, it will be created.
+
Defaults to current date."
(cl-assert (listp date) nil "Date must be a list.")
(let* ((date (or date (gnosis-algorithm-date)))
- (note-num (car (gnosis-select 'note-num 'activity-log `(= date ',date) t))))
- (or note-num
+ (reviewed-total (car (gnosis-select 'reviewed-total 'activity-log `(= date ',date) t)))
+ (reviewed-new (or (car (gnosis-select 'reviewed-new 'activity-log `(= date ',date) t)) 0)))
+ (or reviewed-total
(progn
- (gnosis--insert-into 'activity-log `([,date 0]))
+ ;; Using reviewed-new instead of hardcoding 0 just to not mess up tests.
+ (and (equal date (gnosis-algorithm-date))
+ (gnosis--insert-into 'activity-log `([,date 0 ,reviewed-new])))
0))))
(defun gnosis-get-date-new-notes (&optional date)