Skip to content

Commit

Permalink
Move review-stats function to algorithm implementation
Browse files Browse the repository at this point in the history
  • Loading branch information
l3kn committed Mar 11, 2024
1 parent 0fea284 commit 5e19ceb
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 15 deletions.
15 changes: 15 additions & 0 deletions org-fc-algo-sm2.el
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@
(require 'eieio-base)

(require 'org-fc-core)
(require 'org-fc-awk)

(defmacro org-fc-property (symbol standard doc &rest args)
(let (defcustom-args property)
Expand Down Expand Up @@ -209,6 +210,20 @@ 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-review-stats ((_algo org-fc-algo-sm2))
"Statistics for all card reviews.
Return nil if there is no history file."
(when (file-exists-p org-fc-review-history-file)
(let ((output
(shell-command-to-string
(org-fc-awk--command
"awk/stats_reviews.awk"
:input org-fc-review-history-file
:variables `(("min_box" . ,org-fc-stats-review-min-box))))))
(if (string-prefix-p "(" output)
(read output)
(error "Org-fc shell error: %s" output)))))

;;; Footer

(provide 'org-fc-algo-sm2)
Expand Down
14 changes: 0 additions & 14 deletions org-fc-awk.el
Original file line number Diff line number Diff line change
Expand Up @@ -136,20 +136,6 @@ ITAGS and LTAGS are strings `\":tag1:tag2:\"'"
(read (concat "(" output ")")))
(error "Org-fc shell error: %s" output))))

(defun org-fc-awk-stats-reviews ()
"Statistics for all card reviews.
Return nil there is no history file."
(when (file-exists-p org-fc-review-history-file)
(let ((output
(shell-command-to-string
(org-fc-awk--command
"awk/stats_reviews.awk"
:input org-fc-review-history-file
:variables `(("min_box" . ,org-fc-stats-review-min-box))))))
(if (string-prefix-p "(" output)
(read output)
(error "Org-fc shell error: %s" output)))))

;;; Footer

(provide 'org-fc-awk)
Expand Down
2 changes: 1 addition & 1 deletion org-fc-dashboard.el
Original file line number Diff line number Diff line change
Expand Up @@ -344,7 +344,7 @@ environment without svg support."
(insert "\n")))

(defun org-fc-dashboard-insert-review-stats ()
(let ((reviews-stats (org-fc-awk-stats-reviews)))
(let ((reviews-stats (org-fc-algo-review-stats (org-fc-algo-sm2))))
(insert "\n")
(if reviews-stats
(progn
Expand Down

0 comments on commit 5e19ceb

Please sign in to comment.