mirror of
https://github.com/ankitects/anki.git
synced 2025-09-20 23:12:21 -04:00
fix ordering, add index
This commit is contained in:
parent
f60a536159
commit
57a49e9b08
1 changed files with 11 additions and 3 deletions
14
anki/deck.py
14
anki/deck.py
|
@ -49,7 +49,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=19),
|
Column('version', Integer, nullable=False, default=20),
|
||||||
Column('currentModelId', Integer, ForeignKey("models.id")),
|
Column('currentModelId', Integer, ForeignKey("models.id")),
|
||||||
# syncing
|
# syncing
|
||||||
Column('syncName', UnicodeText),
|
Column('syncName', UnicodeText),
|
||||||
|
@ -1940,6 +1940,9 @@ create index if not exists ix_cards_randomOrder on cards
|
||||||
deck.s.statement("""
|
deck.s.statement("""
|
||||||
create index if not exists ix_cards_priorityDue on cards
|
create index if not exists ix_cards_priorityDue on cards
|
||||||
(type, isDue, priority desc, combinedDue)""")
|
(type, isDue, priority desc, combinedDue)""")
|
||||||
|
deck.s.statement("""
|
||||||
|
create index if not exists ix_cards_priorityDueReal on cards
|
||||||
|
(type, isDue, priority desc, due)""")
|
||||||
# card spacing
|
# card spacing
|
||||||
deck.s.statement("""
|
deck.s.statement("""
|
||||||
create index if not exists ix_cards_factId on cards (factId)""")
|
create index if not exists ix_cards_factId on cards (factId)""")
|
||||||
|
@ -2002,7 +2005,7 @@ order by priority desc, interval""")
|
||||||
create view revCardsDue as
|
create view revCardsDue as
|
||||||
select * from cards
|
select * from cards
|
||||||
where type = 1 and isDue = 1
|
where type = 1 and isDue = 1
|
||||||
order by priority desc, combinedDue""")
|
order by priority desc, due""")
|
||||||
s.statement("""
|
s.statement("""
|
||||||
create view revCardsRandom as
|
create view revCardsRandom as
|
||||||
select * from cards
|
select * from cards
|
||||||
|
@ -2018,7 +2021,7 @@ order by priority desc, factId, ordinal""")
|
||||||
create view acqCardsOrdered as
|
create view acqCardsOrdered as
|
||||||
select * from cards
|
select * from cards
|
||||||
where type = 2 and isDue = 1
|
where type = 2 and isDue = 1
|
||||||
order by priority desc, combinedDue""")
|
order by priority desc, due""")
|
||||||
_addViews = staticmethod(_addViews)
|
_addViews = staticmethod(_addViews)
|
||||||
|
|
||||||
def _upgradeDeck(deck, path):
|
def _upgradeDeck(deck, path):
|
||||||
|
@ -2212,6 +2215,11 @@ where interval < 1""")
|
||||||
deck.s.commit()
|
deck.s.commit()
|
||||||
deck.s.statement("vacuum")
|
deck.s.statement("vacuum")
|
||||||
deck.s.statement("analyze")
|
deck.s.statement("analyze")
|
||||||
|
if deck.version < 20:
|
||||||
|
DeckStorage._addViews(deck)
|
||||||
|
DeckStorage._addIndices(deck)
|
||||||
|
deck.version = 20
|
||||||
|
deck.s.commit()
|
||||||
return deck
|
return deck
|
||||||
_upgradeDeck = staticmethod(_upgradeDeck)
|
_upgradeDeck = staticmethod(_upgradeDeck)
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue