diff --git a/backend/internal/repository/account_repo.go b/backend/internal/repository/account_repo.go index 4e7c418c..a9cb2cba 100644 --- a/backend/internal/repository/account_repo.go +++ b/backend/internal/repository/account_repo.go @@ -1240,82 +1240,6 @@ func isSchedulerNeutralExtraKey(key string) bool { return false } -func shouldSyncSchedulerSnapshotForExtraUpdates(updates map[string]any) bool { - return codexExtraIndicatesRateLimit(updates, "7d") || codexExtraIndicatesRateLimit(updates, "5h") -} - -func codexExtraIndicatesRateLimit(updates map[string]any, window string) bool { - if len(updates) == 0 { - return false - } - usedValue, ok := updates["codex_"+window+"_used_percent"] - if !ok || !extraValueIndicatesExhausted(usedValue) { - return false - } - return extraValueHasResetMarker(updates["codex_"+window+"_reset_at"]) || - extraValueHasPositiveNumber(updates["codex_"+window+"_reset_after_seconds"]) -} - -func extraValueIndicatesExhausted(value any) bool { - number, ok := extraValueToFloat64(value) - return ok && number >= 100-1e-9 -} - -func extraValueHasPositiveNumber(value any) bool { - number, ok := extraValueToFloat64(value) - return ok && number > 0 -} - -func extraValueHasResetMarker(value any) bool { - switch v := value.(type) { - case string: - return strings.TrimSpace(v) != "" - case time.Time: - return !v.IsZero() - case *time.Time: - return v != nil && !v.IsZero() - default: - return false - } -} - -func extraValueToFloat64(value any) (float64, bool) { - switch v := value.(type) { - case float64: - return v, true - case float32: - return float64(v), true - case int: - return float64(v), true - case int8: - return float64(v), true - case int16: - return float64(v), true - case int32: - return float64(v), true - case int64: - return float64(v), true - case uint: - return float64(v), true - case uint8: - return float64(v), true - case uint16: - return float64(v), true - case uint32: - return float64(v), true - case uint64: - return float64(v), true - case json.Number: - parsed, err := v.Float64() - return parsed, err == nil - case string: - parsed, err := strconv.ParseFloat(strings.TrimSpace(v), 64) - return parsed, err == nil - default: - return 0, false - } -} - func (r *accountRepository) BulkUpdate(ctx context.Context, ids []int64, updates service.AccountBulkUpdate) (int64, error) { if len(ids) == 0 { return 0, nil