Changeset View
Changeset View
Standalone View
Standalone View
swh/provenance/postgresql/provenance.py
Show First 20 Lines • Show All 262 Lines • ▼ Show 20 Lines | ) -> Dict[Sha1Git, datetime]: | ||||
sha1s = tuple(ids) | sha1s = tuple(ids) | ||||
if sha1s: | if sha1s: | ||||
# TODO: consider splitting this query in several ones if sha1s is too big! | # TODO: consider splitting this query in several ones if sha1s is too big! | ||||
values = ", ".join(itertools.repeat("%s", len(sha1s))) | values = ", ".join(itertools.repeat("%s", len(sha1s))) | ||||
sql = f""" | sql = f""" | ||||
SELECT sha1, date | SELECT sha1, date | ||||
FROM {entity} | FROM {entity} | ||||
WHERE sha1 IN ({values}) | WHERE sha1 IN ({values}) | ||||
AND date IS NOT NULL | |||||
""" | """ | ||||
self.cursor.execute(sql, sha1s) | self.cursor.execute(sql, sha1s) | ||||
dates.update((row["sha1"], row["date"]) for row in self.cursor.fetchall()) | dates.update((row["sha1"], row["date"]) for row in self.cursor.fetchall()) | ||||
return dates | return dates | ||||
def _entity_set_date( | def _entity_set_date( | ||||
self, | self, | ||||
entity: Literal["content", "directory", "revision"], | entity: Literal["content", "directory", "revision"], | ||||
▲ Show 20 Lines • Show All 95 Lines • Show Last 20 Lines |