diff options
author | Thanos Apollo <[email protected]> | 2024-11-07 09:03:06 +0200 |
---|---|---|
committer | Thanos Apollo <[email protected]> | 2024-11-07 10:12:24 +0200 |
commit | 21d5498e8d0c53b7cc5d5bb813f830d92223b44c (patch) | |
tree | 9e42ffc62530af1e09a35ae400d1dacf5a4f0aee /gnosis.el | |
parent | 596ab975d65122c0f160769e871ea814861816f9 (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.el | 28 |
1 files changed, 18 insertions, 10 deletions
@@ -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. |