This commit is contained in:
@@ -1,11 +1,10 @@
|
||||
import sqlite3
|
||||
import time
|
||||
from datetime import datetime
|
||||
from app.database import DB_PATH, CACHE_EXPIRY_HOURS
|
||||
from app.database import db_manager, CACHE_EXPIRY_HOURS
|
||||
|
||||
def clear_cache():
|
||||
"""Clear the entire cache database"""
|
||||
conn = sqlite3.connect(DB_PATH)
|
||||
conn = db_manager.get_connection()
|
||||
cursor = conn.cursor()
|
||||
cursor.execute("DELETE FROM cache")
|
||||
conn.commit()
|
||||
@@ -14,7 +13,7 @@ def clear_cache():
|
||||
|
||||
def get_cache_stats():
|
||||
"""Get cache statistics"""
|
||||
conn = sqlite3.connect(DB_PATH)
|
||||
conn = db_manager.get_connection()
|
||||
cursor = conn.cursor()
|
||||
|
||||
# Get total entries
|
||||
@@ -27,7 +26,7 @@ def get_cache_stats():
|
||||
|
||||
# Get recent entries (last 24 hours)
|
||||
recent_timestamp = int(time.time()) - (24 * 60 * 60)
|
||||
cursor.execute("SELECT COUNT(*) FROM cache WHERE timestamp > ?", (recent_timestamp,))
|
||||
cursor.execute("SELECT COUNT(*) FROM cache WHERE timestamp > %s", (recent_timestamp,))
|
||||
recent_entries = cursor.fetchone()[0]
|
||||
|
||||
# Get oldest entry timestamp
|
||||
@@ -50,6 +49,7 @@ def get_cache_stats():
|
||||
"recent_entries": recent_entries,
|
||||
"oldest_entry": oldest_date,
|
||||
"newest_entry": newest_date,
|
||||
"cache_expiry_hours": CACHE_EXPIRY_HOURS
|
||||
"cache_expiry_hours": CACHE_EXPIRY_HOURS,
|
||||
"database_type": db_manager.db_type
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user