diff --git a/superscore/backends/filestore.py b/superscore/backends/filestore.py index 7d317cd..613e08b 100644 --- a/superscore/backends/filestore.py +++ b/superscore/backends/filestore.py @@ -286,6 +286,7 @@ def search(self, *search_terms: SearchTermType) -> Generator[Entry, None, None]: Keys are attributes on `Entry` subclasses, or special keywords. Values can be a single value or a tuple of values depending on operator. """ + cached_progeny = cache(self._gather_progeny) with self._load_and_store_context() as db: for entry in db.values(): conditions = [] @@ -294,7 +295,7 @@ def search(self, *search_terms: SearchTermType) -> Generator[Entry, None, None]: if attr == "entry_type": conditions.append(isinstance(entry, target)) elif attr == "ancestor": - conditions.append(entry.uuid in self._gather_progeny(target)) + conditions.append(entry.uuid in cached_progeny(target)) else: try: # check entry attribute by name @@ -305,7 +306,6 @@ def search(self, *search_terms: SearchTermType) -> Generator[Entry, None, None]: if all(conditions): yield entry - @cache def _gather_progeny(self, ancestor: UUID) -> Container[UUID]: """ Finds all entries accessible from ancestor, and returns their UUIDs. This