mirror of
https://github.com/ankitects/anki.git
synced 2025-09-21 15:32:23 -04:00
add search for added time
This commit is contained in:
parent
84501078e8
commit
1e5e574721
3 changed files with 19 additions and 1 deletions
|
@ -86,8 +86,10 @@ def dynExamples():
|
|||
# defaults are resched=True, steps=None, deck=True
|
||||
return [
|
||||
[_("<select preset>"), None],
|
||||
[_("Preview new cards"), dict(
|
||||
[_("Preview all new cards"), dict(
|
||||
search="is:new", resched=False, steps="1", order=5)],
|
||||
[_("Preview cards added today"), dict(
|
||||
search="added:1", resched=False, steps="1", order=5)],
|
||||
[_("Review today's forgotten cards"), dict(
|
||||
search="rated:1:1", order=4)],
|
||||
[_("Review ahead by two days"), dict(
|
||||
|
|
10
anki/find.py
10
anki/find.py
|
@ -151,6 +151,8 @@ class Finder(object):
|
|||
add(self._findProp(val))
|
||||
elif cmd == "rated":
|
||||
add(self._findRated(val))
|
||||
elif cmd == "added":
|
||||
add(self._findAdded(val))
|
||||
else:
|
||||
add(self._findField(cmd, val))
|
||||
# normal text search
|
||||
|
@ -264,6 +266,14 @@ class Finder(object):
|
|||
return ("c.id in (select cid from revlog where id>%d %s)" %
|
||||
(cutoff, ease))
|
||||
|
||||
def _findAdded(self, val):
|
||||
try:
|
||||
days = int(val)
|
||||
except ValueError:
|
||||
return
|
||||
cutoff = (self.col.sched.dayCutoff - 86400*days)*1000
|
||||
return "c.id > %d" % cutoff
|
||||
|
||||
def _findProp(self, val):
|
||||
# extract
|
||||
m = re.match("(^.+?)(<=|>=|!=|=|<|>)(.+?$)", val)
|
||||
|
|
|
@ -207,6 +207,12 @@ def test_findCards():
|
|||
# invalid grouping shouldn't error
|
||||
assert len(deck.findCards(")")) == 0
|
||||
assert len(deck.findCards("(()")) == 0
|
||||
# added
|
||||
assert len(deck.findCards("added:0")) == 0
|
||||
deck.db.execute("update cards set id = id - 86400*1000 where id = ?",
|
||||
id)
|
||||
assert len(deck.findCards("added:1")) == deck.cardCount() - 1
|
||||
assert len(deck.findCards("added:2")) == deck.cardCount()
|
||||
|
||||
def test_findReplace():
|
||||
deck = getEmptyDeck()
|
||||
|
|
Loading…
Reference in a new issue