mirror of
https://github.com/ankitects/anki.git
synced 2025-11-10 14:47:12 -05:00
fix card state negation
This commit is contained in:
parent
437b4780c0
commit
8c1c729544
2 changed files with 9 additions and 6 deletions
14
anki/find.py
14
anki/find.py
|
|
@ -124,6 +124,7 @@ order by %s""" % (lim, sort)
|
|||
"tags %s like :_tag_%d""" % (extra, c))
|
||||
|
||||
def _findCardState(self, val, neg):
|
||||
cond = None
|
||||
if val in ("rev", "new", "lrn"):
|
||||
if val == "rev":
|
||||
n = 2
|
||||
|
|
@ -131,15 +132,16 @@ order by %s""" % (lim, sort)
|
|||
n = 0
|
||||
else:
|
||||
n = 1
|
||||
self.lims['card'].append("type = %d" % n)
|
||||
cond = "type = %d" % n
|
||||
elif val == "suspended":
|
||||
self.lims['card'].append("queue = -1")
|
||||
cond = "queue = -1"
|
||||
elif val == "due":
|
||||
self.lims['card'].append("(queue = 2 and due <= %d)" %
|
||||
self.deck.sched.today)
|
||||
cond = "(queue = 2 and due <= %d)" % self.deck.sched.today
|
||||
elif val == "recent":
|
||||
self.lims['card'].append(
|
||||
"c.id in (select id from cards order by mod desc limit 100)")
|
||||
cond = "c.id in (select id from cards order by mod desc limit 100)"
|
||||
if neg:
|
||||
cond = "not (%s)" % cond
|
||||
self.lims['card'].append(cond)
|
||||
|
||||
def _findText(self, val, neg, c):
|
||||
val = val.replace("*", "%")
|
||||
|
|
|
|||
|
|
@ -58,6 +58,7 @@ def test_findCards():
|
|||
c.due = 0; c.queue = 2
|
||||
c.flush()
|
||||
assert deck.findCards("is:due") == [c.id]
|
||||
assert len(deck.findCards("-is:due")) == 4
|
||||
c.queue = -1
|
||||
# ensure this card gets a later mod time
|
||||
import time; time.sleep(1)
|
||||
|
|
|
|||
Loading…
Reference in a new issue