From 4f1bcb9356c5a76803db74dfc8210dbf989431d3 Mon Sep 17 00:00:00 2001 From: Damien Elmes Date: Tue, 24 Jan 2012 01:04:49 +0900 Subject: [PATCH] fix is:recent --- anki/find.py | 15 ++++++++++++--- 1 file changed, 12 insertions(+), 3 deletions(-) diff --git a/anki/find.py b/anki/find.py index 8456342a4..0cd3e08d3 100644 --- a/anki/find.py +++ b/anki/find.py @@ -46,7 +46,14 @@ class Finder(object): return [] (q, args) = self._whereClause() order = self._order() - query = """\ + if self.lims['recent']: + query = """ +select c.id from cards c, notes n where c.id in ( +select id from cards c where %s limit 100) +and c.nid=n.id +%s""" % (q, order) + else: + query = """\ select c.id from cards c, notes n where %s and c.nid=n.id %s""" % (q, order) res = self.col.db.list(query, **args) @@ -97,7 +104,8 @@ and c.nid=n.id %s""" % (q, order) self.lims = { 'preds': [], 'args': {}, - 'valid': True + 'valid': True, + 'recent': False, } for c, (token, isNeg, type) in enumerate(self._parseQuery()): if type == SEARCH_TAG: @@ -146,7 +154,8 @@ and c.nid=n.id %s""" % (q, order) elif val == "due": cond = "(queue = 2 and due <= %d)" % self.col.sched.today elif val == "recent": - cond = "c.id in (select id from cards order by mod desc limit 100)" + self.lims['recent'] = True + return if neg: cond = "not (%s)" % cond if cond: