fix: update get_noise_floor_history to include offset parameter

This commit is contained in:
Rightup
2026-07-27 22:33:43 +01:00
parent 88dd2a85d8
commit 24673579cd
2 changed files with 9 additions and 5 deletions
+7 -3
View File
@@ -2379,12 +2379,15 @@ class SQLiteHandler:
logger.error(f"Failed to get neighbors: {e}")
return {}
def get_noise_floor_history(self, hours: int = 24, limit: int = None) -> list:
def get_noise_floor_history(self, hours: int = 24, limit: int = None, offset: int = 0) -> list:
try:
cutoff = time.time() - (hours * 3600)
if limit is None:
limit = 1000
limit = max(2000, min(1_000_000, int(hours) * 300))
else:
limit = max(1, min(1_000_000, int(limit)))
offset = max(0, int(offset))
with self._connect() as conn:
conn.row_factory = sqlite3.Row
@@ -2395,9 +2398,10 @@ class SQLiteHandler:
WHERE timestamp > ?
ORDER BY timestamp DESC
LIMIT ?
OFFSET ?
"""
measurements = conn.execute(query, (cutoff, int(limit))).fetchall()
measurements = conn.execute(query, (cutoff, int(limit), offset)).fetchall()
# Reverse to get chronological order (oldest to newest)
result = [
@@ -565,8 +565,8 @@ class StorageCollector:
def cleanup_old_data(self, days: int = 7, companion_events_days: Optional[int] = None):
self.sqlite_handler.cleanup_old_data(days, companion_events_days=companion_events_days)
def get_noise_floor_history(self, hours: int = 24, limit: int = None) -> list:
return self.sqlite_handler.get_noise_floor_history(hours, limit)
def get_noise_floor_history(self, hours: int = 24, limit: int = None, offset: int = 0) -> list:
return self.sqlite_handler.get_noise_floor_history(hours, limit, offset)
def get_noise_floor_stats(self, hours: int = 24) -> dict:
return self.sqlite_handler.get_noise_floor_stats(hours)