Fix IndexError for new cards with areDue / getIntervals

This commit is contained in:
David Bailey 2017-08-12 16:21:04 +01:00
parent a6c15d7bb2
commit 64c61a32fa

View File

@ -416,12 +416,11 @@ class AnkiBridge:
def areDue(self, cards): def areDue(self, cards):
due = [] due = []
for card in cards: for card in cards:
date, ivl = self.collection().db.all('select id/1000.0, ivl from revlog where cid = ?', card)[-1]
if self.findCards('cid:%s is:new' % card): if self.findCards('cid:%s is:new' % card):
due.append(True) due.append(True)
continue continue
date, ivl = self.collection().db.all('select id/1000.0, ivl from revlog where cid = ?', card)[-1]
if (ivl >= -1200): if (ivl >= -1200):
if self.findCards('cid:%s is:due' % card): if self.findCards('cid:%s is:due' % card):
due.append(True) due.append(True)
@ -439,6 +438,10 @@ class AnkiBridge:
def getIntervals(self, cards, complete=False): def getIntervals(self, cards, complete=False):
intervals = [] intervals = []
for card in cards: for card in cards:
if self.findCards('cid:%s is:new' % card):
intervals.append(0)
continue
interval = self.collection().db.list('select ivl from revlog where cid = ?', card) interval = self.collection().db.list('select ivl from revlog where cid = ?', card)
if not complete: if not complete:
interval = interval[-1] interval = interval[-1]