Changeset View
Changeset View
Standalone View
Standalone View
swh/provenance/postgresql/provenance.py
Show First 20 Lines • Show All 84 Lines • ▼ Show 20 Lines | ) -> Generator[psycopg2.extras.RealDictCursor, None, None]: | ||||
with self.conn.cursor(cursor_factory=psycopg2.extras.RealDictCursor) as cur: | with self.conn.cursor(cursor_factory=psycopg2.extras.RealDictCursor) as cur: | ||||
yield cur | yield cur | ||||
@property | @property | ||||
def flavor(self) -> str: | def flavor(self) -> str: | ||||
if self._flavor is None: | if self._flavor is None: | ||||
with self.transaction(readonly=True) as cursor: | with self.transaction(readonly=True) as cursor: | ||||
cursor.execute("SELECT swh_get_dbflavor() AS flavor") | cursor.execute("SELECT swh_get_dbflavor() AS flavor") | ||||
self._flavor = cursor.fetchone()["flavor"] | flavor = cursor.fetchone() | ||||
assert flavor # please mypy | |||||
self._flavor = flavor["flavor"] | |||||
assert self._flavor is not None | assert self._flavor is not None | ||||
return self._flavor | return self._flavor | ||||
@property | @property | ||||
def denormalized(self) -> bool: | def denormalized(self) -> bool: | ||||
return "denormalized" in self.flavor | return "denormalized" in self.flavor | ||||
@statsd.timed(metric=STORAGE_DURATION_METRIC, tags={"method": "close"}) | @statsd.timed(metric=STORAGE_DURATION_METRIC, tags={"method": "close"}) | ||||
▲ Show 20 Lines • Show All 298 Lines • Show Last 20 Lines |