fix negative due dates in filtered decks

https://anki.tenderapp.com/discussions/ankidesktop/35978-rebuilding-filtered-deck-on-experimental-v2-empties-deck-and-reschedules-to-the-year-1745

this means affected cards will not have the selected ordering applied,
but that seems preferable to the alternatives
This commit is contained in:
Damien Elmes 2019-09-24 15:38:33 +10:00
parent 571b711c4c
commit d46899943c
2 changed files with 28 additions and 1 deletions

View file

@ -1079,7 +1079,9 @@ due = (case when odue>0 then odue else due end), odue = 0, odid = 0, usn = ? whe
query = """
update cards set
odid = did, odue = due,
did = ?, due = ?, usn = ?
did = ?,
due = (case when due <= 0 then due else ? end),
usn = ?
%s
where id = ?
""" % queue

View file

@ -1179,3 +1179,28 @@ def test_moveVersions():
col.changeSchedulerVer(1)
c.load()
assert c.due == 50
# cards with a due date earlier than the collection should retain
# their due date when removed
def test_negativeDueFilter():
d = getEmptyCol()
# card due prior to collection date
f = d.newNote()
f['Front'] = "one"; f['Back'] = "two"
d.addNote(f)
c = f.cards()[0]
c.due = -5
c.queue = 2
c.ivl = 5
c.flush()
# into and out of filtered deck
did = d.decks.newDyn("Cram")
d.sched.rebuildDyn(did)
d.sched.emptyDyn(did)
d.reset()
c.load()
assert c.due == -5