mirror of
https://github.com/ankitects/anki.git
synced 2025-09-18 22:12:21 -04:00
don't cap child counts to parents when reviewing in v2
https://forums.ankiweb.net/t/anki-2-1-41-beta/7305/59
When originally implemented in 21023ed3e5
,
a given deck's limit was bound by its parents. This lead to a deck list
that seemed more logical in the parent limit < child limit case, as
child counts couldn't exceed a parent's, but it obscured the fact that
child decks could still be clicked on to show cards. And in the parent
limit > child limit case, the count shown for the child on the deck list
did not reflect how many cards were actually available and would be
delivered.
This change updates the reviewer to ignore parent limits when getting
review counts for the deck, which makes the behaviour consistent with
the deck list, which was recently changed to ignore parent limits.
Neither solution is ideal - this was a tradeoff v2 made in order to keep
fetching of review cards from multiple decks reasonably performant. The
experimental scheduling work moves back to respecting limits on
individual children, so this should hopefully improve in the future.
Also removed _revForDeck(), which was unused.
This commit is contained in:
parent
de7baa80bd
commit
5f9792392a
2 changed files with 3 additions and 45 deletions
|
@ -12,7 +12,7 @@ import anki
|
|||
from anki import hooks
|
||||
from anki.cards import Card
|
||||
from anki.consts import *
|
||||
from anki.decks import Deck, QueueConfig
|
||||
from anki.decks import QueueConfig
|
||||
from anki.schedv2 import Scheduler as V2
|
||||
from anki.utils import ids2str, intTime
|
||||
|
||||
|
@ -428,25 +428,6 @@ and due <= ? limit ?)""",
|
|||
def _deckRevLimit(self, did: int) -> int:
|
||||
return self._deckNewLimit(did, self._deckRevLimitSingle)
|
||||
|
||||
def _deckRevLimitSingle(self, d: Deck) -> int: # type: ignore[override]
|
||||
if d["dyn"]:
|
||||
return self.reportLimit
|
||||
c = self.col.decks.confForDid(d["id"])
|
||||
limit = max(0, c["rev"]["perDay"] - self.counts_for_deck_today(d["id"]).review)
|
||||
return hooks.scheduler_review_limit_for_single_deck(limit, d)
|
||||
|
||||
def _revForDeck(self, did: int, lim: int) -> int: # type: ignore[override]
|
||||
lim = min(lim, self.reportLimit)
|
||||
return self.col.db.scalar(
|
||||
f"""
|
||||
select count() from
|
||||
(select 1 from cards where did = ? and queue = {QUEUE_TYPE_REV}
|
||||
and due <= ? limit ?)""",
|
||||
did,
|
||||
self.today,
|
||||
lim,
|
||||
)
|
||||
|
||||
def _resetRev(self) -> None:
|
||||
self._revQueue: List[Any] = []
|
||||
self._revDids = self.col.decks.active()[:]
|
||||
|
|
|
@ -14,7 +14,7 @@ import anki._backend.backend_pb2 as _pb
|
|||
from anki import hooks
|
||||
from anki.cards import Card
|
||||
from anki.consts import *
|
||||
from anki.decks import Deck, DeckConfig, DeckManager, DeckTreeNode, QueueConfig
|
||||
from anki.decks import Deck, DeckConfig, DeckTreeNode, QueueConfig
|
||||
from anki.lang import FormatTimeSpan
|
||||
from anki.notes import Note
|
||||
from anki.utils import from_json_bytes, ids2str, intTime
|
||||
|
@ -390,9 +390,7 @@ did = ? and queue = {QUEUE_TYPE_DAY_LEARN_RELEARN} and due <= ? limit ?""",
|
|||
d = self.col.decks.get(self.col.decks.selected(), default=False)
|
||||
return self._deckRevLimitSingle(d)
|
||||
|
||||
def _deckRevLimitSingle(
|
||||
self, d: Dict[str, Any], parentLimit: Optional[int] = None
|
||||
) -> int:
|
||||
def _deckRevLimitSingle(self, d: Dict[str, Any]) -> int:
|
||||
# invalid deck selected?
|
||||
if not d:
|
||||
return 0
|
||||
|
@ -403,29 +401,8 @@ did = ? and queue = {QUEUE_TYPE_DAY_LEARN_RELEARN} and due <= ? limit ?""",
|
|||
c = self.col.decks.confForDid(d["id"])
|
||||
lim = max(0, c["rev"]["perDay"] - self.counts_for_deck_today(d["id"]).review)
|
||||
|
||||
if parentLimit is not None:
|
||||
lim = min(parentLimit, lim)
|
||||
elif "::" in d["name"]:
|
||||
for parent in self.col.decks.parents(d["id"]):
|
||||
# pass in dummy parentLimit so we don't do parent lookup again
|
||||
lim = min(lim, self._deckRevLimitSingle(parent, parentLimit=lim))
|
||||
return hooks.scheduler_review_limit_for_single_deck(lim, d)
|
||||
|
||||
def _revForDeck(
|
||||
self, did: int, lim: int, childMap: DeckManager.childMapNode
|
||||
) -> Any:
|
||||
dids = [did] + self.col.decks.childDids(did, childMap)
|
||||
lim = min(lim, self.reportLimit)
|
||||
return self.col.db.scalar(
|
||||
f"""
|
||||
select count() from
|
||||
(select 1 from cards where did in %s and queue = {QUEUE_TYPE_REV}
|
||||
and due <= ? limit ?)"""
|
||||
% ids2str(dids),
|
||||
self.today,
|
||||
lim,
|
||||
)
|
||||
|
||||
def _resetRev(self) -> None:
|
||||
self._revQueue: List[int] = []
|
||||
|
||||
|
|
Loading…
Reference in a new issue