You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Feature Description
Add a macro for Success Rate / Retention. i.e. the percentage of reviews which you passed rather than failed.
I spent a minute looking through the code to see if I could figure out how to add this myself but it's pretty dense so I just added this function to overview.py:
def true_retention(days_back=0, deck='%'):
try:
today = datetime.combine(date.today(), datetime.min.time())
start_date = today - timedelta(days=days_back)
start_epoch = start_date.timestamp() * 1000 # nanoseconds to milliseconds or something
revlog_cmd = f'''
SELECT
r.ease
FROM
revlog r
JOIN cards c ON r.cid = c.id
JOIN decks d ON d.id = c.did
WHERE
r.type = 1
AND r.id > {start_epoch}
AND d.name like '{deck}'
'''
full_revlog = mw.col.db.all(revlog_cmd)
passed = len([_ for _ in full_revlog if _[0] > 1])
flunked = len([_ for _ in full_revlog if _[0] == 1])
if (passed + flunked) < 1:
return 'No reviews'
true_retention = passed / (passed + flunked) * 100
return f'{int(true_retention)}%'
except Exception as e:
print(e)
return 'Error'
And use %eval{true_retention(deck='Deck Name')} as my macro, which seems to be working the way I want it to, but it would be nice if this was integrated.
Great addon, by the way.
The text was updated successfully, but these errors were encountered:
Ope, thanks! Can try to see about adding something that might make this a little easier in the future.
If you wanted to try taking a whack at forking and submitting a PR I can also review that and merge it a little sooner, but I can defs look into combining this with some other requests when I'm more available (hopefully soon, but no guarantees)!
Either way, thanks for suggestion and appreciate the code/write up too!
Feature Description
Add a macro for Success Rate / Retention. i.e. the percentage of reviews which you passed rather than failed.
I spent a minute looking through the code to see if I could figure out how to add this myself but it's pretty dense so I just added this function to overview.py:
And use
%eval{true_retention(deck='Deck Name')}
as my macro, which seems to be working the way I want it to, but it would be nice if this was integrated.Great addon, by the way.
The text was updated successfully, but these errors were encountered: