emacs-elpa-diffs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[nongnu] elpa/gnosis 21d5498e8d 3/8: Refactor review-get-due-notes


From: ELPA Syncer
Subject: [nongnu] elpa/gnosis 21d5498e8d 3/8: Refactor review-get-due-notes
Date: Thu, 7 Nov 2024 04:00:32 -0500 (EST)

branch: elpa/gnosis
commit 21d5498e8d0c53b7cc5d5bb813f830d92223b44c
Author: Thanos Apollo <public@thanosapollo.org>
Commit: Thanos Apollo <public@thanosapollo.org>

    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
---
 gnosis.el | 28 ++++++++++++++++++----------
 1 file changed, 18 insertions(+), 10 deletions(-)

diff --git a/gnosis.el b/gnosis.el
index 610611451b..61f58fe497 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.
 



reply via email to

[Prev in Thread] Current Thread [Next in Thread]