Skip to content

Commit

Permalink
Move full review-data update to algorithm implementation
Browse files Browse the repository at this point in the history
  • Loading branch information
l3kn committed Mar 11, 2024
1 parent ff9ae9f commit 530832d
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 18 deletions.
19 changes: 19 additions & 0 deletions org-fc-algo-sm2.el
Original file line number Diff line number Diff line change
Expand Up @@ -210,6 +210,25 @@ INTERVAL is by a random factor between `org-fc-algo-sm2-fuzz-min' and
nil
org-fc-review-history-file)))

(cl-defmethod org-fc-algo-update-review-data ((algo org-fc-algo-sm2) (position org-fc-position) rating delta)
"Update the review data of a POSITION.
Also add a new entry in the review history file. RATING is a
review rating and DELTA the time in seconds between showing and
rating the card."
(let* ((name (oref position name))
(review-data (org-fc-review-data-parse (org-fc-algo-headers algo)))
(current (org-fc-review-data-get-row review-data name)))

(unless current
(error "No review data row found for this position"))

(org-fc-algo-log-review algo position current rating delta)

(org-fc-review-data-update-row
review-data name
(org-fc-algo-next-review-data algo current rating))
(org-fc-review-data-write review-data)))

(cl-defmethod org-fc-algo-review-stats ((_algo org-fc-algo-sm2))
"Statistics for all card reviews.
Returns nil if there is no history file."
Expand Down
24 changes: 6 additions & 18 deletions org-fc-review.el
Original file line number Diff line number Diff line change
Expand Up @@ -284,28 +284,16 @@ same ID as the current card in the session."
(org-fc-review-next-card))

(defun org-fc-review-update-data (position rating delta)
"Update the review data of a POSITION.
Also add a new entry in the review history file. RATING is a
review rating and DELTA the time in seconds between showing and
rating the card."
"Use the card's spacing algorithm to update the review data of a
POSITION.
RATING is a review rating and DELTA the time in seconds between
showing and rating the card."
(org-fc-with-point-at-entry
;; If the card is marked as a demo card, don't log its reviews and
;; don't update its review data
(unless (member org-fc-demo-tag (org-get-tags))
(let* ((algo (org-fc-algo-sm2))
(name (oref position name))
(review-data (org-fc-review-data-parse (org-fc-algo-headers algo)))
(current (org-fc-review-data-get-row review-data name)))

(unless current
(error "No review data row found for this position"))

(org-fc-algo-log-review algo position current rating delta)

(org-fc-review-data-update-row
review-data name
(org-fc-algo-next-review-data algo current rating))
(org-fc-review-data-write review-data)))))
(let ((algo (org-fc-algo-sm2)))
(org-fc-algo-update-review-data algo position rating delta)))))

(defun org-fc-review-reset ()
"Reset the buffer to its state before the review."
Expand Down

0 comments on commit 530832d

Please sign in to comment.