mirror of
https://github.com/Wei-Shaw/sub2api.git
synced 2026-10-07 13:18:18 +08:00
fix(grok): 修复调度阈值初始化与刷新测试回归
This commit is contained in:
@@ -107,6 +107,24 @@ func (r *grokReconcileRepo) UpdateCredentials(_ context.Context, id int64, crede
|
||||
return nil
|
||||
}
|
||||
|
||||
func (r *grokReconcileRepo) UpdateExtra(_ context.Context, id int64, updates map[string]any) error {
|
||||
r.mu.Lock()
|
||||
defer r.mu.Unlock()
|
||||
for i := range r.accounts {
|
||||
if r.accounts[i].ID != id {
|
||||
continue
|
||||
}
|
||||
if r.accounts[i].Extra == nil {
|
||||
r.accounts[i].Extra = make(map[string]any)
|
||||
}
|
||||
for key, value := range updates {
|
||||
r.accounts[i].Extra[key] = value
|
||||
}
|
||||
break
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
func (r *grokReconcileRepo) SetError(_ context.Context, id int64, message string) error {
|
||||
r.mu.Lock()
|
||||
defer r.mu.Unlock()
|
||||
|
||||
@@ -3916,10 +3916,11 @@ const applyTempUnschedConfig = (credentials: Record<string, unknown>) => {
|
||||
}
|
||||
|
||||
|
||||
const supportsAccountSchedulingThresholdOverridePlatform = (platform: Account['platform'] | undefined) =>
|
||||
platform === 'openai' || platform === 'anthropic' || platform === 'grok'
|
||||
function supportsAccountSchedulingThresholdOverridePlatform(platform: Account['platform'] | undefined) {
|
||||
return platform === 'openai' || platform === 'anthropic' || platform === 'grok'
|
||||
}
|
||||
|
||||
const normalizeAccountSchedulingThresholdOverride = (value: unknown): number | null => {
|
||||
function normalizeAccountSchedulingThresholdOverride(value: unknown): number | null {
|
||||
if (value === null || value === undefined || value === '') {
|
||||
return null
|
||||
}
|
||||
@@ -3934,13 +3935,14 @@ const normalizeAccountSchedulingThresholdOverride = (value: unknown): number | n
|
||||
return integer
|
||||
}
|
||||
|
||||
const clampAccountSchedulingThresholdOverride = (value: unknown): number =>
|
||||
Math.min(100, Math.max(1, Math.trunc(Number(value) || 100)))
|
||||
function clampAccountSchedulingThresholdOverride(value: unknown): number {
|
||||
return Math.min(100, Math.max(1, Math.trunc(Number(value) || 100)))
|
||||
}
|
||||
|
||||
const loadAccountSchedulingThresholdOverride = (
|
||||
function loadAccountSchedulingThresholdOverride(
|
||||
platform: Account['platform'] | undefined,
|
||||
credentials: Record<string, unknown> | undefined
|
||||
) => {
|
||||
) {
|
||||
if (!supportsAccountSchedulingThresholdOverridePlatform(platform)) {
|
||||
accountSchedulingThresholdOverrideEnabled.value = false
|
||||
accountSchedulingThresholdOverrideValue.value = 100
|
||||
|
||||
Reference in New Issue
Block a user