mirror of
https://github.com/ankitects/anki.git
synced 2025-11-10 22:57:11 -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))
|
"tags %s like :_tag_%d""" % (extra, c))
|
||||||
|
|
||||||
def _findCardState(self, val, neg):
|
def _findCardState(self, val, neg):
|
||||||
|
cond = None
|
||||||
if val in ("rev", "new", "lrn"):
|
if val in ("rev", "new", "lrn"):
|
||||||
if val == "rev":
|
if val == "rev":
|
||||||
n = 2
|
n = 2
|
||||||
|
|
@ -131,15 +132,16 @@ order by %s""" % (lim, sort)
|
||||||
n = 0
|
n = 0
|
||||||
else:
|
else:
|
||||||
n = 1
|
n = 1
|
||||||
self.lims['card'].append("type = %d" % n)
|
cond = "type = %d" % n
|
||||||
elif val == "suspended":
|
elif val == "suspended":
|
||||||
self.lims['card'].append("queue = -1")
|
cond = "queue = -1"
|
||||||
elif val == "due":
|
elif val == "due":
|
||||||
self.lims['card'].append("(queue = 2 and due <= %d)" %
|
cond = "(queue = 2 and due <= %d)" % self.deck.sched.today
|
||||||
self.deck.sched.today)
|
|
||||||
elif val == "recent":
|
elif val == "recent":
|
||||||
self.lims['card'].append(
|
cond = "c.id in (select id from cards order by mod desc limit 100)"
|
||||||
"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):
|
def _findText(self, val, neg, c):
|
||||||
val = val.replace("*", "%")
|
val = val.replace("*", "%")
|
||||||
|
|
|
||||||
|
|
@ -58,6 +58,7 @@ def test_findCards():
|
||||||
c.due = 0; c.queue = 2
|
c.due = 0; c.queue = 2
|
||||||
c.flush()
|
c.flush()
|
||||||
assert deck.findCards("is:due") == [c.id]
|
assert deck.findCards("is:due") == [c.id]
|
||||||
|
assert len(deck.findCards("-is:due")) == 4
|
||||||
c.queue = -1
|
c.queue = -1
|
||||||
# ensure this card gets a later mod time
|
# ensure this card gets a later mod time
|
||||||
import time; time.sleep(1)
|
import time; time.sleep(1)
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue