How to search for cards whose last rating was "Again" over a multi-day period?

Hi

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?

1 Like

If the last grade was Again – that was a lapse, and the card is in Relearn, right?
How about: is:learn is:review ? Searching - Anki Manual

1 Like

This excludes learning cards. So a new card which was graded “Again”, “Good”, then “Again”, won’t show up.

Try using this in the console:

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.

4 Likes

Right. I assumed because of the phrasing that the user was looking for lapsed Review cards. Getting Learn cards as well would be even easier.