MCPcopy Create free account
hub / github.com/PierreGode/Ragnar / cleanup_old_wifi_data

Method cleanup_old_wifi_data

db_manager.py:1884–1922  ·  view source on GitHub ↗

Clean up old WiFi data to prevent database bloat. Args: days: Remove data older than this many days

(self, days: int = 30)

Source from the content-addressed store, hash-verified

1882 results.append(result)
1883
1884 return results
1885
1886 except Exception as e:
1887 logger.error(f"Error retrieving WiFi connection history: {e}")
1888 return []
1889
1890 def cleanup_old_wifi_data(self, days: int = 30):
1891 """
1892 Clean up old WiFi data to prevent database bloat.
1893
1894 Args:
1895 days: Remove data older than this many days
1896 """
1897 try:
1898 with self.get_connection() as conn:
1899 cursor = conn.cursor()
1900 cutoff_date = datetime.now() - timedelta(days=days)
1901
1902 # Remove old scan cache
1903 cursor.execute("""
1904 DELETE FROM wifi_scan_cache
1905 WHERE last_seen < ?
1906 """, (cutoff_date,))
1907 scan_deleted = cursor.rowcount
1908
1909 # Remove old connection history
1910 cursor.execute("""
1911 DELETE FROM wifi_connection_history
1912 WHERE connection_time < ?
1913 """, (cutoff_date,))
1914 history_deleted = cursor.rowcount
1915
1916 # Remove analytics for networks not seen in the time period
1917 cursor.execute("""
1918 DELETE FROM wifi_network_analytics
1919 WHERE last_connection_attempt < ?
1920 """, (cutoff_date,))
1921 analytics_deleted = cursor.rowcount
1922
1923 conn.commit()
1924 logger.info(f"Cleaned up old WiFi data: {scan_deleted} scans, "
1925 f"{history_deleted} history, {analytics_deleted} analytics")

Callers

nothing calls this directly

Calls 6

get_connectionMethod · 0.95
cursorMethod · 0.80
commitMethod · 0.80
infoMethod · 0.80
errorMethod · 0.80
executeMethod · 0.45

Tested by

no test coverage detected