This commit is contained in:
@@ -1094,9 +1094,19 @@ func buildHourlyTotals(ctx context.Context, dbConn *sqlx.DB, records []SnapshotR
|
||||
if err := db.ValidateTableName(record.TableName); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
if rowsExist, err := db.TableHasRows(ctx, dbConn, record.TableName); err != nil || !rowsExist {
|
||||
if record.SnapshotCount == 0 {
|
||||
slog.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)
|
||||
}
|
||||
if err != nil || !rowsExist {
|
||||
continue
|
||||
}
|
||||
}
|
||||
query := fmt.Sprintf(`
|
||||
SELECT
|
||||
COUNT(DISTINCT "VmId") AS vm_count,
|
||||
@@ -1184,9 +1194,19 @@ func buildDailyTotals(ctx context.Context, dbConn *sqlx.DB, records []SnapshotRe
|
||||
if err := db.ValidateTableName(record.TableName); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
if rowsExist, err := db.TableHasRows(ctx, dbConn, record.TableName); err != nil || !rowsExist {
|
||||
if record.SnapshotCount == 0 {
|
||||
slog.Debug("daily 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("daily totals snapshot probe failed", "table", record.TableName, "snapshot_time", record.SnapshotTime, "error", err)
|
||||
}
|
||||
if err != nil || !rowsExist {
|
||||
continue
|
||||
}
|
||||
}
|
||||
query := fmt.Sprintf(`
|
||||
SELECT
|
||||
COUNT(DISTINCT "VmId") AS vm_count,
|
||||
|
||||
Reference in New Issue
Block a user