mirror of
https://github.com/ankitects/anki.git
synced 2025-09-24 16:56:36 -04:00
use a single group setting
This commit is contained in:
parent
73625e5751
commit
f75e2af195
5 changed files with 14 additions and 26 deletions
|
@ -18,8 +18,7 @@ import anki.cards, anki.facts, anki.models, anki.template, anki.cram
|
||||||
# Settings related to queue building. These may be loaded without the rest of
|
# Settings related to queue building. These may be loaded without the rest of
|
||||||
# the config to check due counts faster on mobile clients.
|
# the config to check due counts faster on mobile clients.
|
||||||
defaultQconf = {
|
defaultQconf = {
|
||||||
'revGroups': [],
|
'groups': [],
|
||||||
'newGroups': [],
|
|
||||||
'newPerDay': 20,
|
'newPerDay': 20,
|
||||||
'newToday': [0, 0], # currentDay, count
|
'newToday': [0, 0], # currentDay, count
|
||||||
'newTodayOrder': NEW_TODAY_ORD,
|
'newTodayOrder': NEW_TODAY_ORD,
|
||||||
|
@ -574,12 +573,6 @@ update facts set tags = :t, mod = :n where id = :id""", [fix(row) for row in res
|
||||||
select conf from gconf where id = (select gcid from groups where id = ?)""",
|
select conf from gconf where id = (select gcid from groups where id = ?)""",
|
||||||
gid))
|
gid))
|
||||||
|
|
||||||
def activeGroups(self, type):
|
|
||||||
return self.qconf[type+"Groups"]
|
|
||||||
|
|
||||||
def setActiveGroups(self, type, list):
|
|
||||||
self.qconf[type+"Groups"] = list
|
|
||||||
|
|
||||||
def setGroup(self, cids, gid):
|
def setGroup(self, cids, gid):
|
||||||
self.db.execute(
|
self.db.execute(
|
||||||
"update cards set gid = ? where id in "+ids2str(cids), gid)
|
"update cards set gid = ? where id in "+ids2str(cids), gid)
|
||||||
|
|
|
@ -313,6 +313,6 @@ $(function () {
|
||||||
|
|
||||||
def _limit(self):
|
def _limit(self):
|
||||||
if self.selective:
|
if self.selective:
|
||||||
return self.deck.sched._groupLimit("rev")
|
return self.deck.sched._groupLimit()
|
||||||
else:
|
else:
|
||||||
return ""
|
return ""
|
||||||
|
|
|
@ -65,7 +65,7 @@ select due, count() from cards
|
||||||
where queue = 2 %s
|
where queue = 2 %s
|
||||||
and due between ? and ?
|
and due between ? and ?
|
||||||
group by due
|
group by due
|
||||||
order by due""" % self._groupLimit("rev"),
|
order by due""" % self._groupLimit(),
|
||||||
self.today,
|
self.today,
|
||||||
self.today+days-1))
|
self.today+days-1))
|
||||||
for d in range(days):
|
for d in range(days):
|
||||||
|
@ -204,13 +204,13 @@ from cards group by gid""", self.today):
|
||||||
else:
|
else:
|
||||||
self.newCount = self.db.scalar("""
|
self.newCount = self.db.scalar("""
|
||||||
select count() from (select id from cards where
|
select count() from (select id from cards where
|
||||||
queue = 0 %s limit %d)""" % (self._groupLimit('new'), lim))
|
queue = 0 %s limit %d)""" % (self._groupLimit(), lim))
|
||||||
|
|
||||||
def _resetNew(self):
|
def _resetNew(self):
|
||||||
lim = min(self.queueLimit, self.newCount)
|
lim = min(self.queueLimit, self.newCount)
|
||||||
self.newQueue = self.db.all("""
|
self.newQueue = self.db.all("""
|
||||||
select id, due from cards where
|
select id, due from cards where
|
||||||
queue = 0 %s order by due limit %d""" % (self._groupLimit('new'),
|
queue = 0 %s order by due limit %d""" % (self._groupLimit(),
|
||||||
lim))
|
lim))
|
||||||
self.newQueue.reverse()
|
self.newQueue.reverse()
|
||||||
self._updateNewCardRatio()
|
self._updateNewCardRatio()
|
||||||
|
@ -377,14 +377,14 @@ where queue = 1 and type = 2
|
||||||
self.revCount = self.db.scalar("""
|
self.revCount = self.db.scalar("""
|
||||||
select count() from (select id from cards where
|
select count() from (select id from cards where
|
||||||
queue = 2 %s and due <= :lim limit %d)""" % (
|
queue = 2 %s and due <= :lim limit %d)""" % (
|
||||||
self._groupLimit("rev"), self.reportLimit),
|
self._groupLimit(), self.reportLimit),
|
||||||
lim=self.today)
|
lim=self.today)
|
||||||
|
|
||||||
def _resetRev(self):
|
def _resetRev(self):
|
||||||
self.revQueue = self.db.list("""
|
self.revQueue = self.db.list("""
|
||||||
select id from cards where
|
select id from cards where
|
||||||
queue = 2 %s and due <= :lim order by %s limit %d""" % (
|
queue = 2 %s and due <= :lim order by %s limit %d""" % (
|
||||||
self._groupLimit("rev"), self._revOrder(), self.queueLimit),
|
self._groupLimit(), self._revOrder(), self.queueLimit),
|
||||||
lim=self.today)
|
lim=self.today)
|
||||||
if self.deck.qconf['revOrder'] == REV_CARDS_RANDOM:
|
if self.deck.qconf['revOrder'] == REV_CARDS_RANDOM:
|
||||||
random.shuffle(self.revQueue)
|
random.shuffle(self.revQueue)
|
||||||
|
@ -551,10 +551,10 @@ queue = 2 %s and due <= :lim order by %s limit %d""" % (
|
||||||
self.confCache[id] = self.deck.groupConf(id)
|
self.confCache[id] = self.deck.groupConf(id)
|
||||||
return self.confCache[id]
|
return self.confCache[id]
|
||||||
|
|
||||||
def _groupLimit(self, type):
|
def _groupLimit(self):
|
||||||
if not self.useGroups:
|
if not self.useGroups:
|
||||||
return ""
|
return ""
|
||||||
l = self.deck.activeGroups(type)
|
l = self.deck.qconf['groups']
|
||||||
if not l:
|
if not l:
|
||||||
# everything
|
# everything
|
||||||
return ""
|
return ""
|
||||||
|
@ -586,7 +586,7 @@ queue = 2 %s and due <= :lim order by %s limit %d""" % (
|
||||||
self._nextDueMsg())
|
self._nextDueMsg())
|
||||||
|
|
||||||
def _finishedSubtitle(self):
|
def _finishedSubtitle(self):
|
||||||
if self.deck.activeGroups("rev") or self.deck.activeGroups("new"):
|
if self.deck.qconf['groups']:
|
||||||
return _("You have finished the selected groups for now.")
|
return _("You have finished the selected groups for now.")
|
||||||
else:
|
else:
|
||||||
return _("You have finished the deck for now.")
|
return _("You have finished the deck for now.")
|
||||||
|
@ -621,7 +621,7 @@ queue = 2 %s and due <= :lim order by %s limit %d""" % (
|
||||||
"Number of reviews due tomorrow."
|
"Number of reviews due tomorrow."
|
||||||
return self.db.scalar(
|
return self.db.scalar(
|
||||||
"select count() from cards where queue = 2 and due = ?"+
|
"select count() from cards where queue = 2 and due = ?"+
|
||||||
self._groupLimit("rev"),
|
self._groupLimit(),
|
||||||
self.today+1)
|
self.today+1)
|
||||||
|
|
||||||
def newTomorrow(self):
|
def newTomorrow(self):
|
||||||
|
@ -629,7 +629,7 @@ queue = 2 %s and due <= :lim order by %s limit %d""" % (
|
||||||
lim = self.deck.qconf['newPerDay']
|
lim = self.deck.qconf['newPerDay']
|
||||||
return self.db.scalar(
|
return self.db.scalar(
|
||||||
"select count() from (select id from cards where "
|
"select count() from (select id from cards where "
|
||||||
"queue = 0 limit %d)" % lim)
|
"queue = 0 %s limit %d)" % (self._groupLimit(), lim))
|
||||||
|
|
||||||
# Next time reports
|
# Next time reports
|
||||||
##########################################################################
|
##########################################################################
|
||||||
|
|
|
@ -148,11 +148,7 @@ def test_groups():
|
||||||
conf = deck.groupConf(3)
|
conf = deck.groupConf(3)
|
||||||
assert conf == deck.groupConf(1)
|
assert conf == deck.groupConf(1)
|
||||||
# by default, everything should be shown
|
# by default, everything should be shown
|
||||||
assert not deck.activeGroups('rev')
|
assert not deck.qconf['groups']
|
||||||
assert not deck.activeGroups('new')
|
|
||||||
# set new cards to only 'another group'
|
|
||||||
deck.setActiveGroups('new', [3])
|
|
||||||
assert deck.activeGroups('new') == [3]
|
|
||||||
|
|
||||||
def test_selective():
|
def test_selective():
|
||||||
deck = getEmptyDeck()
|
deck = getEmptyDeck()
|
||||||
|
|
|
@ -538,8 +538,7 @@ def test_counts():
|
||||||
# with the default settings, there's no count limit
|
# with the default settings, there's no count limit
|
||||||
assert d.sched.counts() == (2,2,2)
|
assert d.sched.counts() == (2,2,2)
|
||||||
# check limit to one group
|
# check limit to one group
|
||||||
d.qconf['revGroups'] = [1]
|
d.qconf['groups'] = [1]
|
||||||
d.qconf['newGroups'] = [1]
|
|
||||||
d.reset()
|
d.reset()
|
||||||
assert d.sched.counts() == (1,2,1)
|
assert d.sched.counts() == (1,2,1)
|
||||||
# we can disable the groups without forgetting them
|
# we can disable the groups without forgetting them
|
||||||
|
|
Loading…
Reference in a new issue