mirror of
https://github.com/ClusterCockpit/cc-backend
synced 2026-03-15 04:17:30 +01:00
fix: Add defer.close for all queries
This commit is contained in:
@@ -0,0 +1,16 @@
|
||||
All 31 `.Query()` calls now have proper `rows.Close()`. Build passes, tests pass, vet clean.
|
||||
|
||||
### Summary of changes
|
||||
|
||||
**`internal/repository/stats.go`** (7 fixes + 1 rewrite):
|
||||
- Added `defer rows.Close()` + `rows.Err()` to `JobsStatsGrouped`, `JobCountGrouped`, `AddJobCountGrouped`, `jobsStatisticsHistogram`, `jobsDurationStatisticsHistogram`, `jobsMetricStatisticsHistogram`
|
||||
- Rewrote `AddJobCount` to use `QueryRow()` instead of `Query()` (single-row result)
|
||||
|
||||
**`internal/repository/tags.go`** (5 fixes):
|
||||
- Added `defer xrows.Close()` + `xrows.Err()` for `Queryx` in `CountTags`
|
||||
- Added `defer rows.Close()` for second query in `CountTags`
|
||||
- Added `defer rows.Close()` + `rows.Err()` to `GetTags`, `GetTagsDirect`, `getArchiveTags`
|
||||
|
||||
**`internal/repository/node.go`** (4 fixes + 1 rewrite):
|
||||
- Added `defer rows.Close()` + `rows.Err()`, removed manual `rows.Close()` in `QueryNodes`, `QueryNodesWithMeta`, `CountStatesTimed`
|
||||
- Rewrote `CountStates` to use `COUNT(*) ... GROUP BY` in SQL instead of fetching every row and counting in Go
|
||||
Reference in New Issue
Block a user