fix(monitor): read the error frequency for AI context from the real errors table columns

This commit is contained in:
MacRimi
2026-11-04 16:57:51 +01:00
parent 8ca445ff3b
commit 7cbe92ad9f
+5 -11
View File
@@ -165,22 +165,16 @@ def get_event_frequency(error_id: str = None, error_key: str = None,
try: try:
cursor = conn.cursor() cursor = conn.cursor()
# Try to find the error # Try to find the error. The errors table keys a row by error_key.
if error_id: if error_id or error_key:
cursor.execute(''' cursor.execute('''
SELECT first_seen, last_seen, occurrences, category SELECT first_seen, last_seen, occurrence_count, category
FROM errors WHERE error_key = ? OR error_id = ?
ORDER BY last_seen DESC LIMIT 1
''', (error_id, error_id))
elif error_key:
cursor.execute('''
SELECT first_seen, last_seen, occurrences, category
FROM errors WHERE error_key = ? FROM errors WHERE error_key = ?
ORDER BY last_seen DESC LIMIT 1 ORDER BY last_seen DESC LIMIT 1
''', (error_key,)) ''', (error_id or error_key,))
elif category: elif category:
cursor.execute(''' cursor.execute('''
SELECT first_seen, last_seen, occurrences, category SELECT first_seen, last_seen, occurrence_count, category
FROM errors WHERE category = ? AND resolved_at IS NULL FROM errors WHERE category = ? AND resolved_at IS NULL
ORDER BY last_seen DESC LIMIT 1 ORDER BY last_seen DESC LIMIT 1
''', (category,)) ''', (category,))