summaryrefslogtreecommitdiff
path: root/gnosis.el
diff options
context:
space:
mode:
authorThanos Apollo <[email protected]>2024-11-07 09:03:06 +0200
committerThanos Apollo <[email protected]>2024-11-07 10:12:24 +0200
commit21d5498e8d0c53b7cc5d5bb813f830d92223b44c (patch)
tree9e42ffc62530af1e09a35ae400d1dacf5a4f0aee /gnosis.el
parent596ab975d65122c0f160769e871ea814861816f9 (diff)
Refactor review-get-due-notes
* Create #'gnosis-review-get--due-notes that returns due note ids and due dates * Create #'gnosis-review-get-due-notes that uses the above functions output but only returns due ids * This is done to improve perfomance & to reduce sql query calls
Diffstat (limited to 'gnosis.el')
-rw-r--r--gnosis.el28
1 files changed, 18 insertions, 10 deletions
diff --git a/gnosis.el b/gnosis.el
index 6106114..61f58fe 100644
--- a/gnosis.el
+++ b/gnosis.el
@@ -1469,22 +1469,30 @@ well."
(let ((next-rev (gnosis-get 'next-rev 'review-log `(= id ,id))))
(gnosis-past-or-present-p next-rev)))
-(defun gnosis-review-get-due-notes ()
- "Return a list due notes id for current date."
- (let* ((old-notes (cl-loop for note in (gnosis-select 'id 'review-log '(and (> n 0)
- (= suspend 0))
- t)
- when (gnosis-review-is-due-p note)
+(defun gnosis-review-get--due-notes ()
+ "Return due note IDs & due dates."
+ (let* ((old-notes (cl-loop for note in
+ (gnosis-select '[id next-rev] 'review-log
+ '(and (> n 0)
+ (= suspend 0))
+ nil)
+ when (gnosis-past-or-present-p (cadr note))
collect note))
- (new-notes (cl-loop for note in (gnosis-select 'id 'review-log '(and (= n 0)
- (= suspend 0))
- t)
- when (gnosis-review-is-due-today-p note)
+ (new-notes (cl-loop for note in
+ (gnosis-select '[id next-rev] 'review-log
+ '(and (= n 0)
+ (= suspend 0))
+ nil)
+ when (gnosis-past-or-present-p (cadr note))
collect note)))
(if gnosis-review-new-first
(append (cl-subseq new-notes 0 gnosis-new-notes-limit) old-notes)
(append old-notes (cl-subseq new-notes 0 gnosis-new-notes-limit)))))
+(defun gnosis-review-get-due-notes ()
+ "Return all due note IDs."
+ (mapcar #'car (gnosis-review-get--due-notes)))
+
(defun gnosis-review-get-overdue-notes (&optional note-ids)
"Return overdue notes for current DATE.