immediate_parent
This commit is contained in:
parent
285e9280cf
commit
64bb71e5bd
@ -306,6 +306,12 @@ class DeckManager:
|
||||
def immediate_parent_path(cls, name: str) -> Any:
|
||||
return cls._path(name)[:-1]
|
||||
|
||||
@classmethod
|
||||
def immediate_parent(cls, name: str) -> Any:
|
||||
pp = cls.immediate_parent_path(name)
|
||||
if pp:
|
||||
return "::".join(pp)
|
||||
|
||||
@classmethod
|
||||
def key(cls, deck: Dict[str, Any]) -> List[str]:
|
||||
return cls.path(deck["name"])
|
||||
@ -485,7 +491,7 @@ class DeckManager:
|
||||
|
||||
# immediate parent must exist
|
||||
if "::" in deck["name"]:
|
||||
immediateParent = "::".join(self.immediate_parent_path(deck["name"]))
|
||||
immediateParent = self.immediate_parent(deck["name"])
|
||||
if immediateParent not in names:
|
||||
self.col.log("fix deck with missing parent", deck["name"])
|
||||
self._ensureParents(deck["name"])
|
||||
@ -588,9 +594,8 @@ class DeckManager:
|
||||
childMap[deck["id"]] = node
|
||||
|
||||
# add note to immediate parent
|
||||
immediate_parent_path = self.immediate_parent_path(deck["name"])
|
||||
if immediate_parent_path:
|
||||
immediateParent = "::".join(immediate_parent_path)
|
||||
immediateParent = self.immediate_parent(deck["name"])
|
||||
if immediateParent is not None:
|
||||
pid = nameMap[immediateParent]["id"]
|
||||
childMap[pid][deck["id"]] = node
|
||||
|
||||
|
@ -153,18 +153,11 @@ class Scheduler(V2):
|
||||
lims: Dict[str, List[int]] = {}
|
||||
data = []
|
||||
|
||||
def parent(name):
|
||||
parts = DeckManager.path(name)
|
||||
if len(parts) < 2:
|
||||
return None
|
||||
parts = parts[:-1]
|
||||
return "::".join(parts)
|
||||
|
||||
for deck in decks:
|
||||
p = parent(deck["name"])
|
||||
p = DeckManager.immediate_parent(deck["name"])
|
||||
# new
|
||||
nlim = self._deckNewLimitSingle(deck)
|
||||
if p:
|
||||
if p is not None:
|
||||
nlim = min(nlim, lims[p][0])
|
||||
new = self._newForDeck(deck["id"], nlim)
|
||||
# learning
|
||||
|
@ -240,19 +240,12 @@ order by due"""
|
||||
lims: Dict[str, List[int]] = {}
|
||||
data = []
|
||||
|
||||
def parent(name):
|
||||
parts = DeckManager.path(name)
|
||||
if len(parts) < 2:
|
||||
return None
|
||||
parts = parts[:-1]
|
||||
return "::".join(parts)
|
||||
|
||||
childMap = self.col.decks.childMap()
|
||||
for deck in decks:
|
||||
p = parent(deck["name"])
|
||||
p = DeckManager.immediate_parent(deck["name"])
|
||||
# new
|
||||
nlim = self._deckNewLimitSingle(deck)
|
||||
if p:
|
||||
if p is not None:
|
||||
nlim = min(nlim, lims[p][0])
|
||||
new = self._newForDeck(deck["id"], nlim)
|
||||
# learning
|
||||
|
Loading…
Reference in New Issue
Block a user