mirror of
https://github.com/ankitects/anki.git
synced 2025-09-21 07:22:23 -04:00
use the id to sort instead of requiring ordinal
This means that the default learn queue sort order doesn't need another column in the index, but it also means that generated cards will have a higher id, and would appear later even if they have a lower ordinal. This is probably an infrequent issue, and a plugin which rewrites ids would probably be an adequate solution.
This commit is contained in:
parent
ad68500494
commit
3f92254e1a
2 changed files with 10 additions and 10 deletions
|
@ -391,7 +391,7 @@ due > :now and due < :now""", now=time.time())
|
|||
ncards = 0
|
||||
isRandom = self.qconf['newCardOrder'] == NEW_CARDS_RANDOM
|
||||
if isRandom:
|
||||
due = random.randrange(0, 10000)
|
||||
due = random.randrange(0, 1000000)
|
||||
# flush the fact so we get its id
|
||||
fact.flush()
|
||||
for template in cms:
|
||||
|
@ -1464,8 +1464,6 @@ seq > :s and seq <= :e order by seq desc""", s=start, e=end)
|
|||
def updateDynamicIndices(self):
|
||||
# determine required columns
|
||||
required = []
|
||||
if self.qconf['newTodayOrder'] == NEW_TODAY_ORD:
|
||||
required.append("ord")
|
||||
if self.qconf['revCardOrder'] in (REV_CARDS_OLD_FIRST, REV_CARDS_NEW_FIRST):
|
||||
required.append("interval")
|
||||
cols = ["queue", "due", "gid"] + required
|
||||
|
|
|
@ -98,19 +98,21 @@ class Scheduler(object):
|
|||
self.newCount = 0
|
||||
else:
|
||||
self.newQueue = self.db.all("""
|
||||
select id %s from cards where
|
||||
queue = 2 %s order by due limit %d""" % (self.newOrder(), self.groupLimit('new'),
|
||||
select id, due from cards where
|
||||
queue = 2 %s order by due, id limit %d""" % (self.groupLimit('new'),
|
||||
lim))
|
||||
self.newQueue.sort(key=itemgetter(1), reverse=True)
|
||||
self.newQueue.reverse()
|
||||
self.newCount = len(self.newQueue)
|
||||
self.updateNewCardRatio()
|
||||
|
||||
def getNewCard(self):
|
||||
if self.newQueue:
|
||||
return self.newQueue.pop()[0]
|
||||
|
||||
def newOrder(self):
|
||||
return (",ord", "")[self.deck.qconf['newTodayOrder']]
|
||||
(id, due) = self.newQueue.pop()
|
||||
# move any siblings to the end?
|
||||
if self.deck.qconf['newTodayOrder'] == NEW_TODAY_ORD:
|
||||
while self.newQueue and self.newQueue[-1][1] == due:
|
||||
self.newQueue.insert(0, self.newQueue.pop())
|
||||
return id
|
||||
|
||||
def updateNewCardRatio(self):
|
||||
if self.deck.qconf['newCardSpacing'] == NEW_CARDS_DISTRIBUTE:
|
||||
|
|
Loading…
Reference in a new issue