From e72d2dc67439d880d93739fe003d451c6c790ae3 Mon Sep 17 00:00:00 2001 From: Thanos Apollo Date: Tue, 23 Jul 2024 18:46:49 +0300 Subject: [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. --- gnosis.el | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) (limited to 'gnosis.el') 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) -- cgit v1.2.3