From 0bac2310feaf6d560f820a0f17fdba67663fa29f Mon Sep 17 00:00:00 2001 From: Alex Riina Date: Sun, 15 Mar 2020 13:53:48 -0400 Subject: [PATCH 1/3] tdon't reschedule suspended cards Every time reposition runs, it lists all IR cards and sorts them, but this includes suspended cards which interrupts what I think is a good workflow https://github.com/luoliyan/incremental-reading/issues/96 My ideal work flow would be - add new document - break out sections - create cards from sections - suspend the remaining IR cards This allows the suspending part of the workflow to continue working. --- ir/schedule.py | 3 ++- tests/test_scheduler.py | 1 + 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/ir/schedule.py b/ir/schedule.py index 89ac3c7..d361b16 100644 --- a/ir/schedule.py +++ b/ir/schedule.py @@ -33,6 +33,7 @@ ) from anki.utils import stripHTML +from anki.consts import QUEUE_TYPE_SUSPENDED from aqt import mw from aqt.utils import showInfo, tooltip @@ -284,7 +285,7 @@ def _getCardInfo(self, did): cardInfo = [] for cid, nid in mw.col.db.execute( - 'select id, nid from cards where did = ?', did + f'select id, nid from cards where did = ? and queue <> {QUEUE_TYPE_SUSPENDED}', did ): note = mw.col.getNote(nid) if note.model()['name'] == self.settings['modelName']: diff --git a/tests/test_scheduler.py b/tests/test_scheduler.py index 16725a4..bb04024 100644 --- a/tests/test_scheduler.py +++ b/tests/test_scheduler.py @@ -10,6 +10,7 @@ def setUp(self): 'PyQt5.QtWidgets': MagicMock(), 'anki': MagicMock(), 'anki.utils': MagicMock(), + 'anki.consts': MagicMock(), 'aqt': MagicMock(), 'aqt.utils': MagicMock(), 'ir.main': MagicMock(), From 1a9dc6285c5aaa28c45bc616179fa89dddd017e0 Mon Sep 17 00:00:00 2001 From: Alex Riina Date: Mon, 21 Jun 2021 23:06:15 -0400 Subject: [PATCH 2/3] rewrite to pass test --- ir/schedule.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/ir/schedule.py b/ir/schedule.py index d361b16..7ebb31f 100644 --- a/ir/schedule.py +++ b/ir/schedule.py @@ -285,7 +285,7 @@ def _getCardInfo(self, did): cardInfo = [] for cid, nid in mw.col.db.execute( - f'select id, nid from cards where did = ? and queue <> {QUEUE_TYPE_SUSPENDED}', did + f'select id, nid from cards where did = ? and queue <> ?', did, QUEUE_TYPE_SUSPENDED ): note = mw.col.getNote(nid) if note.model()['name'] == self.settings['modelName']: From e351ea647e74a5b8fff4703939dd7310a5bebe12 Mon Sep 17 00:00:00 2001 From: Alex Riina Date: Mon, 21 Jun 2021 23:06:57 -0400 Subject: [PATCH 3/3] remove extra f"" --- ir/schedule.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/ir/schedule.py b/ir/schedule.py index 7ebb31f..fb899f2 100644 --- a/ir/schedule.py +++ b/ir/schedule.py @@ -285,7 +285,7 @@ def _getCardInfo(self, did): cardInfo = [] for cid, nid in mw.col.db.execute( - f'select id, nid from cards where did = ? and queue <> ?', did, QUEUE_TYPE_SUSPENDED + 'select id, nid from cards where did = ? and queue <> ?', did, QUEUE_TYPE_SUSPENDED ): note = mw.col.getNote(nid) if note.model()['name'] == self.settings['modelName']: