aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorFuwn <[email protected]>2026-01-20 06:34:00 -0800
committerFuwn <[email protected]>2026-01-20 06:34:00 -0800
commit881e2db620e46572cddccd09da4c2416ea3eb81c (patch)
tree9e42611460483c4a4a22a6d0613c3dabe0517cb7
parentfeat: Add uptime tooltip showing last failure time and reason (diff)
downloadkaze-881e2db620e46572cddccd09da4c2416ea3eb81c.tar.xz
kaze-881e2db620e46572cddccd09da4c2416ea3eb81c.zip
fix: Use correct column name error_message in last failure query
-rw-r--r--internal/storage/sqlite.go12
1 files changed, 7 insertions, 5 deletions
diff --git a/internal/storage/sqlite.go b/internal/storage/sqlite.go
index ce62e67..e441fe7 100644
--- a/internal/storage/sqlite.go
+++ b/internal/storage/sqlite.go
@@ -379,13 +379,13 @@ func (s *Storage) GetAllMonitorStats(ctx context.Context) (map[string]*MonitorSt
// Get last failure for each monitor
rows, err = s.db.QueryContext(ctx, `
- SELECT monitor_name, timestamp, error
+ SELECT monitor_name, timestamp, error_message
FROM check_results
- WHERE status != 'up' AND error != ''
+ WHERE status != 'up'
AND (monitor_name, timestamp) IN (
SELECT monitor_name, MAX(timestamp)
FROM check_results
- WHERE status != 'up' AND error != ''
+ WHERE status != 'up'
GROUP BY monitor_name
)
`)
@@ -397,13 +397,15 @@ func (s *Storage) GetAllMonitorStats(ctx context.Context) (map[string]*MonitorSt
for rows.Next() {
var name string
var timestamp time.Time
- var errorMsg string
+ var errorMsg sql.NullString
if err := rows.Scan(&name, &timestamp, &errorMsg); err != nil {
return nil, fmt.Errorf("failed to scan last failure: %w", err)
}
if ms, ok := stats[name]; ok {
ms.LastFailure = &timestamp
- ms.LastFailureError = errorMsg
+ if errorMsg.Valid {
+ ms.LastFailureError = errorMsg.String
+ }
}
}