Skip to content

Commit

Permalink
Allow reading the history of a card/position
Browse files Browse the repository at this point in the history
  • Loading branch information
l3kn committed Mar 11, 2024
1 parent 5c6e354 commit ed4c55f
Show file tree
Hide file tree
Showing 2 changed files with 42 additions and 1 deletion.
26 changes: 26 additions & 0 deletions awk/review_history_sm2.awk
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
BEGIN {
FS = "\t"
print "("
}

{
date = $1;
file_path = $2;
card_id = $3;
position_name = $4;
rating = $8;

if ((filter_card_id == "any" || filter_card_id == card_id) && \
(filter_position_name == "any" || filter_position_name == position_name)) {
print "(" \
":date " escape_string(date) \
" :card_id " escape_string(card_id) \
" :position_name " escape_string(position_name) \
" :rating " escape_string(rating) \
")"
}
}

END {
print ")"
}
17 changes: 16 additions & 1 deletion org-fc-algo-sm2.el
Original file line number Diff line number Diff line change
Expand Up @@ -212,7 +212,7 @@ INTERVAL is by a random factor between `org-fc-algo-sm2-fuzz-min' and

(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."
Returns nil if there is no history file."
(when (file-exists-p org-fc-review-history-file)
(let ((output
(shell-command-to-string
Expand All @@ -224,6 +224,21 @@ Return nil if there is no history file."
(read output)
(error "Org-fc shell error: %s" output)))))

(cl-defmethod org-fc-algo-review-history ((_algo org-fc-algo-sm2) card-id position-name)
"Review history for a given CARD-ID and POSITION name.
Returns 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/review_history_sm2.awk"
:input org-fc-review-history-file
:variables `(("filter_card_id" . ,(or card-id "any"))
("filter_position_name" . ,(or position-name "any")))))))
(if (string-prefix-p "(" output)
(read output)
(error "Org-fc shell error: %s" output)))))

;;; Footer

(provide 'org-fc-algo-sm2)
Expand Down

0 comments on commit ed4c55f

Please sign in to comment.