From 988b24dd10d5bdb60be76a794a558020f3158ac9 Mon Sep 17 00:00:00 2001 From: Thanos Apollo Date: Fri, 26 Jul 2024 18:04:23 +0300 Subject: New function: Add dashboard--streak * Return consecutive review streak. --- gnosis-dashboard.el | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/gnosis-dashboard.el b/gnosis-dashboard.el index 7b17239..d317ad3 100644 --- a/gnosis-dashboard.el +++ b/gnosis-dashboard.el @@ -80,6 +80,18 @@ do (setq notes (append notes (list (gnosis-get-date-total-notes date))))) notes)) +(defun gnosis-dashboard--streak (dates &optional num date) + "Return current review streak. + +DATES: Dates in the activity log. +NUM: Streak number. +DATE: Integer, used with `gnosis-algorithm-date' to get previous dates." + (let ((num (or num 0)) + (date (or date 0))) + (if (member (gnosis-algorithm-date date) dates) + (gnosis-dashboard--streak dates (cl-incf num) (- date 1)) + num))) + (defun gnosis-dashboard-month-reviews (month) "Return reviewes for MONTH in current year." (cl-assert (and (integerp month) -- cgit v1.2.3