up extractor env getting

This commit is contained in:
Tykayn 2025-09-18 22:30:25 +02:00 committed by tykayn
parent 4951eeb1c8
commit 153e9bd8f9
11 changed files with 196 additions and 4 deletions

View file

@ -34,6 +34,13 @@ class StatsResource:
count = cur.fetchone()[0]
logger.debug(f"Estimated event count: {count}")
# If the estimated count is negative, fall back to an actual count
if count < 0:
logger.warning(f"Estimated event count is negative ({count}), falling back to COUNT(*)")
cur.execute("SELECT COUNT(*) FROM events;")
count = cur.fetchone()[0]
logger.debug(f"Actual event count: {count}")
# Global info
cur.execute("SELECT max(lastupdate) as last_updated, current_timestamp-pg_postmaster_start_time() from events;")
pg_stats = cur.fetchone()