diff --git a/anki/cards.py b/anki/cards.py index 2eac98669..5a8539ea5 100644 --- a/anki/cards.py +++ b/anki/cards.py @@ -62,6 +62,7 @@ cardsTable = Table( Column('spaceUntil', Float, nullable=False, default=0), Column('isDue', Boolean, nullable=False, default=0), Column('type', Integer, nullable=False, default=2), + Column('relativeDelay', Float, nullable=False, default=0), # obsolete Column('combinedDue', Integer, nullable=False, default=0)) class Card(object): @@ -75,6 +76,9 @@ class Card(object): self.isDue = True self.timerStarted = False self.timerStopped = False + self.modified = time.time() + self.due = self.modified + self.combinedDue = self.modified if fact: self.fact = fact if cardModel: @@ -248,7 +252,8 @@ noCount=:noCount, spaceUntil = :spaceUntil, isDue = :isDue, type = :type, -combinedDue = max(:spaceUntil, :due) +combinedDue = max(:spaceUntil, :due), +relativeDelay = 0 where id=:id""", self.__dict__) mapper(Card, cardsTable, properties={ @@ -260,8 +265,6 @@ mapper(Card, cardsTable, properties={ mapper(Fact, factsTable, properties={ 'model': relation(Model), 'fields': relation(Field, backref="fact", order_by=Field.c.ordinal), - 'lastCard': relation(Card, post_update=True, primaryjoin= - cardsTable.c.id == factsTable.c.lastCardId), }) diff --git a/anki/deck.py b/anki/deck.py index f585f7bf4..2abe4a14b 100644 --- a/anki/deck.py +++ b/anki/deck.py @@ -305,7 +305,7 @@ end)""" + where) "select count(*) from failedCardsSoon") self.revCount = self.s.scalar("select count(*) from revCards") self.newCount = self.s.scalar("select count(*) from acqCardsOrdered") - print "rebuild counts", time.time() - t + #print "rebuild counts", time.time() - t def checkDue(self): "Mark expired cards due, and update counts." diff --git a/anki/sync.py b/anki/sync.py index 0c085549d..b73ab9d85 100644 --- a/anki/sync.py +++ b/anki/sync.py @@ -526,7 +526,8 @@ priority, interval, lastInterval, due, lastDue, factor, firstAnswered, reps, successive, averageTime, reviewTime, youngEase0, youngEase1, youngEase2, youngEase3, youngEase4, matureEase0, matureEase1, matureEase2, matureEase3, matureEase4, yesCount, noCount, -question, answer, lastFactor, spaceUntil, isDue, type, combinedDue) +question, answer, lastFactor, spaceUntil, isDue, type, combinedDue, +relativeDelay) values (:id, :factId, :cardModelId, :created, :modified, :tags, :ordinal, :priority, :interval, :lastInterval, :due, :lastDue, :factor, @@ -534,7 +535,7 @@ values :youngEase1, :youngEase2, :youngEase3, :youngEase4, :matureEase0, :matureEase1, :matureEase2, :matureEase3, :matureEase4, :yesCount, :noCount, :question, :answer, :lastFactor, :spaceUntil, :isDue, -:type, :combinedDue)""", dlist) +:type, :combinedDue, 0)""", dlist) self.deck.s.statement( "delete from cardsDeleted where cardId in %s" % ids2str([c[0] for c in cards])) @@ -802,7 +803,8 @@ priority, interval, lastInterval, due, lastDue, factor, firstAnswered, reps, successive, averageTime, reviewTime, youngEase0, youngEase1, youngEase2, youngEase3, youngEase4, matureEase0, matureEase1, matureEase2, matureEase3, matureEase4, yesCount, noCount, -question, answer, lastFactor, spaceUntil, isDue, type, combinedDue) +question, answer, lastFactor, spaceUntil, isDue, type, combinedDue, +relativeDelay) values (:id, :factId, :cardModelId, :created, :t, "", :ordinal, 1, 0, 0, :created, 0, 2.5, diff --git a/tests/test_exporting.py b/tests/test_exporting.py index 295309618..6fe7cceaa 100644 --- a/tests/test_exporting.py +++ b/tests/test_exporting.py @@ -41,7 +41,6 @@ def test_export_anki(): e.limitTags = ['tag'] e.exportInto(newname) d2 = DeckStorage.Deck(newname) - print d2.cardCount assert d2.cardCount == 2 @nose.with_setup(setup1)