mirror of
https://github.com/ankitects/anki.git
synced 2025-11-11 07:07:13 -05:00
fix the review history growing bug properly
This commit is contained in:
parent
ba15b6d0c3
commit
b527d31499
3 changed files with 11 additions and 7 deletions
10
anki/deck.py
10
anki/deck.py
|
|
@ -54,7 +54,7 @@ decksTable = Table(
|
||||||
Column('created', Float, nullable=False, default=time.time),
|
Column('created', Float, nullable=False, default=time.time),
|
||||||
Column('modified', Float, nullable=False, default=time.time),
|
Column('modified', Float, nullable=False, default=time.time),
|
||||||
Column('description', UnicodeText, nullable=False, default=u""),
|
Column('description', UnicodeText, nullable=False, default=u""),
|
||||||
Column('version', Integer, nullable=False, default=29),
|
Column('version', Integer, nullable=False, default=30),
|
||||||
Column('currentModelId', Integer, ForeignKey("models.id")),
|
Column('currentModelId', Integer, ForeignKey("models.id")),
|
||||||
# syncing
|
# syncing
|
||||||
Column('syncName', UnicodeText),
|
Column('syncName', UnicodeText),
|
||||||
|
|
@ -2714,13 +2714,17 @@ where interval < 1""")
|
||||||
deck.s.statement("pragma default_cache_size= 20000")
|
deck.s.statement("pragma default_cache_size= 20000")
|
||||||
deck.version = 28
|
deck.version = 28
|
||||||
deck.s.commit()
|
deck.s.commit()
|
||||||
if deck.version < 29:
|
if deck.version < 30:
|
||||||
# remove duplicates from review history
|
# remove duplicates from review history
|
||||||
deck.s.statement("""
|
deck.s.statement("""
|
||||||
delete from reviewHistory where id not in (
|
delete from reviewHistory where id not in (
|
||||||
select min(id) from reviewHistory group by cardId, time);""")
|
select min(id) from reviewHistory group by cardId, time);""")
|
||||||
|
# add a unique index to prevent them from appearing
|
||||||
|
deck.s.statement("""
|
||||||
|
create unique index ix_reviewHistory_unique
|
||||||
|
on reviewHistory (cardId, time)""")
|
||||||
deck.s.statement("vacuum")
|
deck.s.statement("vacuum")
|
||||||
deck.version = 29
|
deck.version = 30
|
||||||
deck.s.commit()
|
deck.s.commit()
|
||||||
# this check we do regardless of version number since doing it on init
|
# this check we do regardless of version number since doing it on init
|
||||||
# seems to crash
|
# seems to crash
|
||||||
|
|
|
||||||
|
|
@ -18,8 +18,7 @@ from anki.db import *
|
||||||
|
|
||||||
reviewHistoryTable = Table(
|
reviewHistoryTable = Table(
|
||||||
'reviewHistory', metadata,
|
'reviewHistory', metadata,
|
||||||
Column('id', Integer, primary_key=True),
|
Column('cardId', Integer),
|
||||||
Column('cardId', Integer, ForeignKey("cards.id")),
|
|
||||||
Column('time', Float, nullable=False, default=time.time),
|
Column('time', Float, nullable=False, default=time.time),
|
||||||
Column('lastInterval', Float, nullable=False),
|
Column('lastInterval', Float, nullable=False),
|
||||||
Column('nextInterval', Float, nullable=False),
|
Column('nextInterval', Float, nullable=False),
|
||||||
|
|
@ -30,7 +29,8 @@ reviewHistoryTable = Table(
|
||||||
Column('reps', Float, nullable=False),
|
Column('reps', Float, nullable=False),
|
||||||
Column('thinkingTime', Float, nullable=False),
|
Column('thinkingTime', Float, nullable=False),
|
||||||
Column('yesCount', Float, nullable=False),
|
Column('yesCount', Float, nullable=False),
|
||||||
Column('noCount', Float, nullable=False))
|
Column('noCount', Float, nullable=False),
|
||||||
|
PrimaryKeyConstraint("cardId", "time"))
|
||||||
|
|
||||||
class CardHistoryEntry(object):
|
class CardHistoryEntry(object):
|
||||||
"Create after rescheduling card."
|
"Create after rescheduling card."
|
||||||
|
|
|
||||||
|
|
@ -627,7 +627,7 @@ from reviewHistory where time > :ls""",
|
||||||
if not dlist:
|
if not dlist:
|
||||||
return
|
return
|
||||||
self.deck.s.statements("""
|
self.deck.s.statements("""
|
||||||
insert into reviewHistory
|
insert or ignore into reviewHistory
|
||||||
(cardId, time, lastInterval, nextInterval, ease, delay,
|
(cardId, time, lastInterval, nextInterval, ease, delay,
|
||||||
lastFactor, nextFactor, reps, thinkingTime, yesCount, noCount)
|
lastFactor, nextFactor, reps, thinkingTime, yesCount, noCount)
|
||||||
values
|
values
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue