diff --git a/swh/provenance/postgresql/archive.py b/swh/provenance/postgresql/archive.py --- a/swh/provenance/postgresql/archive.py +++ b/swh/provenance/postgresql/archive.py @@ -87,10 +87,15 @@ {"type": row[0], "target": row[1], "name": row[2]} for row in cursor ] + def revision_get_parents(self, id: Sha1Git) -> Iterable[Sha1Git]: + parents = self._revision_get_parents(id) + yield from parents + + @lru_cache(maxsize=100000) @statsd.timed( metric=ARCHIVE_DURATION_METRIC, tags={"method": "revision_get_parents"} ) - def revision_get_parents(self, id: Sha1Git) -> Iterable[Sha1Git]: + def _revision_get_parents(self, id: Sha1Git) -> List[Sha1Git]: with self.conn.cursor() as cursor: cursor.execute( """ @@ -101,7 +106,7 @@ """, (id,), ) - yield from (row[0] for row in cursor) + return [row[0] for row in cursor] @statsd.timed(metric=ARCHIVE_DURATION_METRIC, tags={"method": "snapshot_get_heads"}) def snapshot_get_heads(self, id: Sha1Git) -> Iterable[Sha1Git]: