From 81daad878e819ae59df0ac5f7226004c71582d8e Mon Sep 17 00:00:00 2001 From: Arthur Milchior Date: Tue, 11 Feb 2020 16:20:37 -0800 Subject: [PATCH] Factorizing card's flush --- pylib/anki/cards.py | 15 +++++---------- 1 file changed, 5 insertions(+), 10 deletions(-) diff --git a/pylib/anki/cards.py b/pylib/anki/cards.py index 2de6960e5..a31c0fb81 100644 --- a/pylib/anki/cards.py +++ b/pylib/anki/cards.py @@ -84,7 +84,7 @@ class Card: self._render_output = None self._note = None - def flush(self) -> None: + def _preFlush(self) -> none: self.mod = intTime() self.usn = self.col.usn() # bug check @@ -95,6 +95,9 @@ class Card: ): hooks.card_odue_was_invalid() assert self.due < 4294967296 + + def flush(self) -> None: + self._preFlush() self.col.db.execute( """ insert or replace into cards values @@ -121,16 +124,8 @@ insert or replace into cards values self.col.log(self) def flushSched(self) -> None: - self.mod = intTime() - self.usn = self.col.usn() + self._preFlush() # bug checks - if ( - self.queue == QUEUE_TYPE_REV - and self.odue - and not self.col.decks.isDyn(self.did) - ): - hooks.card_odue_was_invalid() - assert self.due < 4294967296 self.col.db.execute( """update cards set mod=?, usn=?, type=?, queue=?, due=?, ivl=?, factor=?, reps=?,