improve concurrency handling for inventory job
Some checks failed
continuous-integration/drone/push Build encountered an error
Some checks failed
continuous-integration/drone/push Build encountered an error
This commit is contained in:
@@ -44,8 +44,8 @@ func boolStringFromInterface(value interface{}) string {
|
||||
}
|
||||
|
||||
// latestHourlySnapshotBefore finds the most recent hourly snapshot table prior to the given time, skipping empty tables.
|
||||
func latestHourlySnapshotBefore(ctx context.Context, dbConn *sqlx.DB, cutoff time.Time) (string, error) {
|
||||
tables, err := listLatestHourlyWithRows(ctx, dbConn, "", cutoff.Unix(), 1, nil)
|
||||
func latestHourlySnapshotBefore(ctx context.Context, dbConn *sqlx.DB, cutoff time.Time, logger *slog.Logger) (string, error) {
|
||||
tables, err := listLatestHourlyWithRows(ctx, dbConn, "", cutoff.Unix(), 1, logger)
|
||||
if err != nil {
|
||||
return "", err
|
||||
}
|
||||
@@ -103,7 +103,7 @@ LIMIT ?
|
||||
continue
|
||||
}
|
||||
probed := false
|
||||
hasRows := true
|
||||
hasRows := count.Valid && count.Int64 > 0
|
||||
start := time.Now()
|
||||
if !count.Valid {
|
||||
probed = true
|
||||
@@ -141,12 +141,12 @@ LIMIT ?
|
||||
return out, nil
|
||||
}
|
||||
|
||||
// SnapshotTooSoon reports whether the gap between prev and curr is significantly shorter than expected (default: <50% interval).
|
||||
// SnapshotTooSoon reports whether the gap between prev and curr is significantly shorter than expected.
|
||||
func SnapshotTooSoon(prevUnix, currUnix int64, expectedSeconds int64) bool {
|
||||
if prevUnix == 0 || currUnix == 0 || expectedSeconds <= 0 {
|
||||
return false
|
||||
}
|
||||
return currUnix-prevUnix < expectedSeconds/2
|
||||
return currUnix-prevUnix < expectedSeconds
|
||||
}
|
||||
|
||||
// querySnapshotRows builds a SELECT with proper rebind for the given table/columns/where.
|
||||
|
||||
Reference in New Issue
Block a user