mirror of
https://github.com/ankitects/anki.git
synced 2025-09-23 08:22:24 -04:00
add short interval alternatives
This commit is contained in:
parent
c8bae8002f
commit
12e4953dc9
2 changed files with 25 additions and 9 deletions
11
anki/deck.py
11
anki/deck.py
|
@ -300,9 +300,10 @@ where isDue = 0 and priority in (1,2,3,4) and combinedDue < :now""",
|
|||
set relativeDelay = interval / (strftime("%s", "now") - due + 1)
|
||||
where isDue = 1""")
|
||||
|
||||
def rebuildQueue(self):
|
||||
def rebuildQueue(self, updateRelative=True):
|
||||
"Update relative delays based on current time."
|
||||
self.updateRelativeDelays()
|
||||
if updateRelative:
|
||||
self.updateRelativeDelays()
|
||||
self.markExpiredCardsDue()
|
||||
# cache global/daily stats
|
||||
self._globalStats = globalStats(self)
|
||||
|
@ -466,7 +467,7 @@ order by combinedDue limit 1""")
|
|||
select count(id) from cards where combinedDue < :time
|
||||
and priority != 0 and type != 2""", time=time)
|
||||
|
||||
def nextIntervalStr(self, card, ease):
|
||||
def nextIntervalStr(self, card, ease, short=False):
|
||||
"Return the next interval for CARD given EASE as a string."
|
||||
delay = self._adjustedDelay(card, ease)
|
||||
if card.due > time.time() and ease < 2:
|
||||
|
@ -484,11 +485,11 @@ and priority != 0 and type != 2""", time=time)
|
|||
interval[0] = interval[0] * 86400.0
|
||||
interval[1] = interval[1] * 86400.0
|
||||
if interval[0] != interval[1]:
|
||||
return anki.utils.fmtTimeSpanPair(*interval)
|
||||
return anki.utils.fmtTimeSpanPair(interval[0], interval[1], short=short)
|
||||
interval = interval[0]
|
||||
else:
|
||||
interval = self.nextInterval(card, ease) * 86400.0
|
||||
return anki.utils.fmtTimeSpan(interval)
|
||||
return anki.utils.fmtTimeSpan(interval, short=short)
|
||||
|
||||
def deckFinishedMsg(self):
|
||||
return _('''
|
||||
|
|
|
@ -22,20 +22,35 @@ timeTable = {
|
|||
"seconds": lambda n: ngettext("%s second", "%s seconds", n),
|
||||
}
|
||||
|
||||
def fmtTimeSpan(time, pad=0, point=0):
|
||||
shortTimeTable = {
|
||||
"years": "%sy",
|
||||
"months": "%sm",
|
||||
"days": "%sd",
|
||||
"hours": "%sh",
|
||||
"minutes": "%sm",
|
||||
"seconds": "%ss",
|
||||
}
|
||||
|
||||
def fmtTimeSpan(time, pad=0, point=0, short=False):
|
||||
"Return a string representing a time span (eg '2 days')."
|
||||
(type, point) = optimalPeriod(time, point)
|
||||
time = convertSecondsTo(time, type)
|
||||
fmt = timeTable[type](_pluralCount(round(time, point)))
|
||||
if short:
|
||||
fmt = shortTimeTable[type]
|
||||
else:
|
||||
fmt = timeTable[type](_pluralCount(round(time, point)))
|
||||
timestr = "%(a)d.%(b)df" % {'a': pad, 'b': point}
|
||||
return ("%" + (fmt % timestr)) % time
|
||||
|
||||
def fmtTimeSpanPair(time1, time2):
|
||||
def fmtTimeSpanPair(time1, time2, short=False):
|
||||
(type, point) = optimalPeriod(time1, 0)
|
||||
time1 = convertSecondsTo(time1, type)
|
||||
time2 = convertSecondsTo(time2, type)
|
||||
# a pair is always should always be read as plural
|
||||
fmt = timeTable[type](2)
|
||||
if short:
|
||||
fmt = shortTimeTable[type]
|
||||
else:
|
||||
fmt = timeTable[type](2)
|
||||
timestr = "%(a)d.%(b)df" % {'a': 0, 'b': point}
|
||||
finalstr = "%s-%s" % (
|
||||
('%' + timestr) % time1,
|
||||
|
|
Loading…
Reference in a new issue