fix(account): prevent quota-exceeded API key/Bedrock accounts from being scheduled
Add quota exceeded check to IsSchedulable() and refactor shouldClearStickySession to delegate to IsSchedulable(), eliminating duplicated logic and fixing missed overload/rate-limit/expired checks. Frontend displays quota exceeded status independently via quota fields.
This commit is contained in:
@@ -284,6 +284,16 @@ const hasError = computed(() => {
|
||||
return props.account.status === 'error'
|
||||
})
|
||||
|
||||
const isQuotaExceeded = computed(() => {
|
||||
const exceeded = (used?: number | null, limit?: number | null) =>
|
||||
typeof limit === 'number' && limit > 0 && typeof used === 'number' && used >= limit
|
||||
return (
|
||||
exceeded(props.account.quota_used, props.account.quota_limit) ||
|
||||
exceeded(props.account.quota_daily_used, props.account.quota_daily_limit) ||
|
||||
exceeded(props.account.quota_weekly_used, props.account.quota_weekly_limit)
|
||||
)
|
||||
})
|
||||
|
||||
// Computed: countdown text for rate limit (429)
|
||||
const rateLimitCountdown = computed(() => {
|
||||
return formatCountdown(props.account.rate_limit_reset_at)
|
||||
@@ -307,19 +317,16 @@ const statusClass = computed(() => {
|
||||
if (isTempUnschedulable.value) {
|
||||
return 'badge-warning'
|
||||
}
|
||||
if (props.account.status !== 'active') {
|
||||
return props.account.status === 'error' ? 'badge-danger' : 'badge-gray'
|
||||
}
|
||||
if (isQuotaExceeded.value) {
|
||||
return 'badge-warning'
|
||||
}
|
||||
if (!props.account.schedulable) {
|
||||
return 'badge-gray'
|
||||
}
|
||||
switch (props.account.status) {
|
||||
case 'active':
|
||||
return 'badge-success'
|
||||
case 'inactive':
|
||||
return 'badge-gray'
|
||||
case 'error':
|
||||
return 'badge-danger'
|
||||
default:
|
||||
return 'badge-gray'
|
||||
}
|
||||
return 'badge-success'
|
||||
})
|
||||
|
||||
// Computed: status text
|
||||
@@ -330,6 +337,12 @@ const statusText = computed(() => {
|
||||
if (isTempUnschedulable.value) {
|
||||
return t('admin.accounts.status.tempUnschedulable')
|
||||
}
|
||||
if (props.account.status !== 'active') {
|
||||
return t(`admin.accounts.status.${props.account.status}`)
|
||||
}
|
||||
if (isQuotaExceeded.value) {
|
||||
return t('admin.accounts.status.quotaExceeded')
|
||||
}
|
||||
if (!props.account.schedulable) {
|
||||
return t('admin.accounts.status.paused')
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user