summaryrefslogtreecommitdiff
path: root/gnosis.el
diff options
context:
space:
mode:
authorThanos Apollo <[email protected]>2024-01-09 10:39:15 +0200
committerThanos Apollo <[email protected]>2024-01-09 10:39:15 +0200
commit8d06a7b303e46a5409516f87ea5ba3b7657b42fd (patch)
tree7d04c6895a1c3daa183a7fe7de5051972f8a5537 /gnosis.el
parent542d6ad2cf21e6afde421c58999c8e68701301a1 (diff)
Rewrite gnosis-review-get-due-notes
Diffstat (limited to 'gnosis.el')
-rw-r--r--gnosis.el20
1 files changed, 9 insertions, 11 deletions
diff --git a/gnosis.el b/gnosis.el
index b9e7d04..d587dee 100644
--- a/gnosis.el
+++ b/gnosis.el
@@ -392,6 +392,7 @@ NOTE: If a gnosis--insert-into fails, the whole transaction will be
constraint."
(condition-case nil
(progn
+ ;; Refer to `gnosis-db-schema-SCHEMA' e.g `gnosis-db-schema-review-log'
(gnosis--insert-into 'notes `([nil ,type ,main ,options ,answer ,tags ,(gnosis--get-deck-id deck)]))
(gnosis--insert-into 'review `([nil ,gnosis-algorithm-ef ,gnosis-algorithm-ff ,gnosis-algorithm-interval]))
(gnosis--insert-into 'review-log `([nil ,(gnosis-algorithm-date) ,(gnosis-algorithm-date) 0 0 0 0 ,suspend 0]))
@@ -766,6 +767,14 @@ This function ignores if note is suspended. Refer to
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 ((notes (gnosis-select 'id 'notes)))
+ (cl-loop for note in (apply #'append notes)
+ when (gnosis-review-is-due-p note)
+ collect note)))
+
(defun gnosis-review--algorithm (id success)
"Return next review date & ef for note with value of id ID.
@@ -778,17 +787,6 @@ Returns a list of the form ((yyyy mm dd) ef)."
(gnosis-get 'n 'review-log `(= id ,id))
ef success ff c-success)))
-
-(defun gnosis-review-get-due-notes ()
- "Return a list due notes id for current date.
-
-Select notes where:
- - Next review date <= current date
- - Not suspended."
- (apply #'append
- (emacsql gnosis-db `[:select [id] :from review-log :where (and (<= next-rev ',(gnosis-algorithm-date))
- (= suspend 0))])))
-
(defun gnosis-review-due-notes--with-tags ()
"Return a list of due note tags."
(let ((due-notes (gnosis-review-get-due-notes)))