Private
Public Access
1
0

style: format Go code with gofumpt
All checks were successful
continuous-integration/drone/push Build is passing
continuous-integration/drone/tag Build is passing

Apply consistent formatting to Go source files using gofumpt
as required by pre-commit guidelines.
This commit is contained in:
2025-08-03 16:06:59 -07:00
parent 3e6a0f9e63
commit 2dfc355f7c
9 changed files with 21 additions and 25 deletions

View File

@@ -24,15 +24,16 @@ type ServerTotals map[string]uint64
func (s ServerQueries) Len() int {
return len(s)
}
func (s ServerQueries) Swap(i, j int) {
s[i], s[j] = s[j], s[i]
}
func (s ServerQueries) Less(i, j int) bool {
return s[i].Count > s[j].Count
}
func (d *ClickHouse) ServerAnswerCounts(ctx context.Context, serverIP string, days int) (ServerQueries, error) {
ctx, span := tracing.Tracer().Start(ctx, "ServerAnswerCounts")
defer span.End()

View File

@@ -114,7 +114,7 @@ func (d *ClickHouse) LogscoresTimeRange(ctx context.Context, serverID, monitorID
defer span.End()
args := []interface{}{serverID, from, to}
query := `select id,monitor_id,server_id,ts,
toFloat64(score),toFloat64(step),offset,
rtt,leap,warning,error
@@ -131,15 +131,15 @@ func (d *ClickHouse) LogscoresTimeRange(ctx context.Context, serverID, monitorID
// Always order by timestamp ASC for Grafana convention
query += " order by ts ASC"
// Apply limit to prevent memory issues
if limit > 0 {
query += " limit ?"
args = append(args, limit)
}
log.DebugContext(ctx, "clickhouse time range query",
"query", query,
log.DebugContext(ctx, "clickhouse time range query",
"query", query,
"args", args,
"server_id", serverID,
"monitor_id", monitorID,
@@ -205,7 +205,7 @@ func (d *ClickHouse) LogscoresTimeRange(ctx context.Context, serverID, monitorID
rv = append(rv, row)
}
log.InfoContext(ctx, "time range query results",
log.InfoContext(ctx, "time range query results",
"rows_returned", len(rv),
"server_id", serverID,
"monitor_id", monitorID,
@@ -214,13 +214,15 @@ func (d *ClickHouse) LogscoresTimeRange(ctx context.Context, serverID, monitorID
"sample_rows", func() []map[string]interface{} {
samples := make([]map[string]interface{}, 0, 3)
for i, row := range rv {
if i >= 3 { break }
if i >= 3 {
break
}
samples = append(samples, map[string]interface{}{
"id": row.ID,
"monitor_id": row.MonitorID,
"ts": row.Ts.Format(time.RFC3339),
"score": row.Score,
"rtt_valid": row.Rtt.Valid,
"id": row.ID,
"monitor_id": row.MonitorID,
"ts": row.Ts.Format(time.RFC3339),
"score": row.Score,
"rtt_valid": row.Rtt.Valid,
"offset_valid": row.Offset.Valid,
})
}