From 7694ff81c523428f60a06e6c5ef6e8f28dd41c32 Mon Sep 17 00:00:00 2001 From: Damien Elmes Date: Thu, 3 Mar 2011 02:42:52 +0900 Subject: [PATCH] replace old selective study with new lists; fix upgrade - instead of the old 4 settings, we move to just two, as there's no point having separate include and exclude options for a non-overlapping set of cards - revGroups and newGroups are a list of groupIds to include in the queue. If all groups are enabled, the UI should set it to an empty list rather than a list of every available group, and groupLimit() will leave off the constraint completely --- anki/deck.py | 6 ++---- anki/sched.py | 30 +++++------------------------- anki/upgrade.py | 11 +++++++---- 3 files changed, 14 insertions(+), 33 deletions(-) diff --git a/anki/deck.py b/anki/deck.py index dd98bd822..ee7a520f2 100644 --- a/anki/deck.py +++ b/anki/deck.py @@ -32,10 +32,8 @@ import anki.models, anki.facts, anki.cards, anki.media, anki.groups, anki.graves # Settings related to queue building. These may be loaded without the rest of # the config to check due counts faster on mobile clients. defaultQconf = { - 'newActive': u"", - 'newInactive': u"", - 'revActive': u"", - 'revInactive': u"", + 'revGroups': [], + 'newGroups': [], 'newPerDay': 20, 'newToday': [0, 0], # currentDay, count 'newTodayOrder': NEW_TODAY_ORDINAL, diff --git a/anki/sched.py b/anki/sched.py index 880ea5785..68a9f103e 100644 --- a/anki/sched.py +++ b/anki/sched.py @@ -477,31 +477,11 @@ and queue between 1 and 2""", "update cards set queue = type where queue = -3") def groupLimit(self, type): - #return " and groupId in (1)" - print "fixme: groupLimit()" - return "" - - def cardLimit(self, active, inactive, sql): - yes = parseTags(self.deck.qconf.get(active)) - no = parseTags(self.deck.qconf.get(inactive)) - if yes: - yids = tagIds(self.db, yes).values() - nids = tagIds(self.db, no).values() - return sql.replace( - "where", - "where +c.id in (select cardId from cardTags where " - "tagId in %s) and +c.id not in (select cardId from " - "cardTags where tagId in %s) and" % ( - ids2str(yids), - ids2str(nids))) - elif no: - nids = tagIds(self.db, no).values() - return sql.replace( - "where", - "where +c.id not in (select cardId from cardTags where " - "tagId in %s) and" % ids2str(nids)) - else: - return sql + l = self.deck.qconf[type+"Groups"] + if not l: + # everything + return "" + return " and groupId in %s" % ids2str(l) # Daily cutoff ########################################################################## diff --git a/anki/upgrade.py b/anki/upgrade.py index a5997a0f6..d299c09cc 100644 --- a/anki/upgrade.py +++ b/anki/upgrade.py @@ -95,19 +95,22 @@ ifnull(syncName, ""), lastSync, utcOffset, "", "", "" from decks""") keys = ("newActive", "newInactive", "revActive", "revInactive") for k in keys: s.execute("delete from deckVars where key=:k", {'k':k}) + # copy other settings + keys = ("newCardOrder", "newCardSpacing", "revCardOrder") + for k in keys: + qconf[k] = s.execute("select %s from decks" % k).scalar() qconf['newPerDay'] = s.execute( "select newCardsPerDay from decks").scalar() # fetch remaining settings from decks table conf = deck.defaultConf.copy() data = {} - keys = ("newCardOrder", "newCardSpacing", "revCardOrder", - "sessionRepLimit", "sessionTimeLimit") + keys = ("sessionRepLimit", "sessionTimeLimit") for k in keys: conf[k] = s.execute("select %s from decks" % k).scalar() # random and due options merged - conf['revCardOrder'] = min(2, conf['revCardOrder']) + qconf['revCardOrder'] = min(2, qconf['revCardOrder']) # no reverse option anymore - conf['newCardOrder'] = min(1, conf['newCardOrder']) + qconf['newCardOrder'] = min(1, qconf['newCardOrder']) # add any deck vars and save dkeys = ("hexCache", "cssCache") for (k, v) in s.execute("select * from deckVars").fetchall():