fix bugs in merge, fix slow spacedCardCount()

This commit is contained in:
Damien Elmes 2008-11-08 17:41:40 +09:00
parent 014896478f
commit 6cb968c10a

View file

@ -622,8 +622,7 @@ suspended</a> cards.''') % {
def suspendedCardCount(self): def suspendedCardCount(self):
return self.s.scalar(""" return self.s.scalar("""
"select count(id) from cards where type in (0,1,2) and priority = 0") select count(id) from cards where type in (0,1,2) and priority = 0""")
and priority = 0""")
def seenCardCount(self): def seenCardCount(self):
return self.s.scalar( return self.s.scalar(
@ -642,9 +641,8 @@ and priority = 0""")
def spacedCardCount(self): def spacedCardCount(self):
return self.s.scalar(""" return self.s.scalar("""
select count(cards.id) from cards where select count(cards.id) from cards where
type in (1,2) and isDue = 0 and priority in (1,2,3,4) and due < :now""", type in (1,2) and isDue = 0 and priority in (1,2,3,4) and combinedDue > :now
priority in (1,2,3,4) and due < :now and spaceUntil > :now""", and due < :now""", now=time.time())
now=time.time())
def isEmpty(self): def isEmpty(self):
return not self.cardCount return not self.cardCount
@ -1571,7 +1569,7 @@ alter table decks add column sessionTimeLimit integer not null default 1800""")
if ver < 11: if ver < 11:
s.execute(""" s.execute("""
alter table decks add column utcOffset numeric(10, 2) not null default 0""") alter table decks add column utcOffset numeric(10, 2) not null default 0""")
if ver < 12: if ver < 13:
s.execute(""" s.execute("""
alter table decks add column cardCount integer not null default 0""") alter table decks add column cardCount integer not null default 0""")
s.execute(""" s.execute("""