diff --git a/anki/decks.py b/anki/decks.py index e284fe072..029a7ae6a 100644 --- a/anki/decks.py +++ b/anki/decks.py @@ -473,7 +473,7 @@ class DeckManager: actv.append((g['name'], g['id'])) return actv - def parents(self, did): + def parents(self, did, nameMap=None): "All parents of did." # get parent and grandparent names parents = [] @@ -484,7 +484,11 @@ class DeckManager: parents.append(parents[-1] + "::" + part) # convert to objects for c, p in enumerate(parents): - parents[c] = self.get(self.id(p)) + if nameMap: + deck = nameMap[p] + else: + deck = self.get(self.id(p)) + parents[c] = deck return parents def parentsByName(self, name): @@ -503,6 +507,9 @@ class DeckManager: return parents + def nameMap(self): + return dict((d['name'], d) for d in self.decks.values()) + # Sync handling ########################################################################## diff --git a/anki/sched.py b/anki/sched.py index be6242b85..19fc17275 100644 --- a/anki/sched.py +++ b/anki/sched.py @@ -183,6 +183,7 @@ order by due""" % self._deckLimit(), tot = 0 pcounts = {} # for each of the active decks + nameMap = self.col.decks.nameMap() for did in self.col.decks.active(): # early alphas were setting the active ids as a str did = int(did) @@ -191,7 +192,7 @@ order by due""" % self._deckLimit(), if not lim: continue # check the parents - parents = self.col.decks.parents(did) + parents = self.col.decks.parents(did, nameMap) for p in parents: # add if missing if p['id'] not in pcounts: diff --git a/anki/schedv2.py b/anki/schedv2.py index edb18093c..de0f99588 100644 --- a/anki/schedv2.py +++ b/anki/schedv2.py @@ -171,6 +171,7 @@ order by due""" % self._deckLimit(), tot = 0 pcounts = {} # for each of the active decks + nameMap = self.col.decks.nameMap() for did in self.col.decks.active(): # early alphas were setting the active ids as a str did = int(did) @@ -179,7 +180,7 @@ order by due""" % self._deckLimit(), if not lim: continue # check the parents - parents = self.col.decks.parents(did) + parents = self.col.decks.parents(did, nameMap) for p in parents: # add if missing if p['id'] not in pcounts: