This commit is contained in:
@@ -809,7 +809,7 @@ func addTotalsChartSheet(logger *slog.Logger, database db.Database, ctx context.
|
||||
if err != nil || len(records) == 0 {
|
||||
return
|
||||
}
|
||||
points, err := buildHourlyTotals(ctx, database.DB(), records)
|
||||
points, err := buildHourlyTotals(ctx, logger, database.DB(), records)
|
||||
if err != nil || len(points) == 0 {
|
||||
return
|
||||
}
|
||||
@@ -1077,7 +1077,10 @@ type totalsPoint struct {
|
||||
GoldTotal float64
|
||||
}
|
||||
|
||||
func buildHourlyTotals(ctx context.Context, dbConn *sqlx.DB, records []SnapshotRecord) ([]totalsPoint, error) {
|
||||
func buildHourlyTotals(ctx context.Context, logger *slog.Logger, dbConn *sqlx.DB, records []SnapshotRecord) ([]totalsPoint, error) {
|
||||
if logger == nil {
|
||||
logger = slog.Default()
|
||||
}
|
||||
type hourBucket struct {
|
||||
samples int
|
||||
vmSum float64
|
||||
@@ -1096,13 +1099,13 @@ func buildHourlyTotals(ctx context.Context, dbConn *sqlx.DB, records []SnapshotR
|
||||
return nil, err
|
||||
}
|
||||
if record.SnapshotCount == 0 {
|
||||
slog.Debug("hourly totals skipping empty snapshot", "table", record.TableName, "snapshot_time", record.SnapshotTime)
|
||||
logger.Debug("hourly totals skipping empty snapshot", "table", record.TableName, "snapshot_time", record.SnapshotTime)
|
||||
continue
|
||||
}
|
||||
if record.SnapshotCount < 0 {
|
||||
rowsExist, err := db.TableHasRows(ctx, dbConn, record.TableName)
|
||||
if err != nil {
|
||||
slog.Debug("hourly totals snapshot probe failed", "table", record.TableName, "snapshot_time", record.SnapshotTime, "error", err)
|
||||
logger.Debug("hourly totals snapshot probe failed", "table", record.TableName, "snapshot_time", record.SnapshotTime, "error", err)
|
||||
}
|
||||
if err != nil || !rowsExist {
|
||||
continue
|
||||
@@ -1193,7 +1196,7 @@ FROM (
|
||||
bronzeAvg := bucket.bronzeSum / denom
|
||||
silverAvg := bucket.silverSum / denom
|
||||
goldAvg := bucket.goldSum / denom
|
||||
slog.Debug(
|
||||
logger.Debug(
|
||||
"hourly totals bucket",
|
||||
"hour_start", time.Unix(key, 0).Local().Format("2006-01-02 15:00"),
|
||||
"samples", bucket.samples,
|
||||
|
||||
Reference in New Issue
Block a user