I’m trying to filter my most recent review was “Again” (failed). For a single day, this works fine:
rated:1:1 -rated:1:2 -rated:1:3 -rated:1:4
This finds cards I pressed Again today.
Now I want to extend this to a longer period, say the last 30 days. My naive attempt is:
rated:30:1 -rated:30:2 -rated:30:3 -rated:30:4
But this doesn’t do what I want. It excludes any card that has any Good/Easy rating in the last 30 days, regardless of order. For example, consider this review history over 30 days:
Day 1: Again
Day 2: Again
Day 3: Good
Day 4: Again ← the most recent review
I want this card to be included because the last rating is Again. However, the search above would exclude it because there is a Good on day 3 within the 30‑day window.
Any idea to filter cards have most recent review that rating was Again?
from aqt import mw
card_ids = mw.col.find_cards("rated:30")
result = []
for cid in card_ids:
rev = mw.col.db.first(
"select ease from revlog where cid=? order by id desc limit 1",
cid
)
if rev and rev[0] == 1: # 1 = Again 2 = Hard 3 = Good 4 = Easy
result.append(str(cid))
if result:
print("cid:" + ",".join(result))
else:
print("No matching cards found.")
You then need to copy-paste the results in the Card Browser.