mirror of
https://github.com/zyycn/codex-proxy-rs.git
synced 2026-11-07 00:05:49 +00:00
Compare commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
d425428ebe | ||
|
|
b26d3b386a |
@@ -367,7 +367,7 @@ impl ProviderAccountRepository for PgProviderAccountRepository {
|
||||
require_nonempty(ENTITY, "account_id", account_id)?;
|
||||
let result = sqlx::query(
|
||||
"update provider_accounts
|
||||
set quota_observed_at = $3
|
||||
set quota_observed_at = $3, updated_at = greatest(now(), $3)
|
||||
where id = $1 and credential_revision = $2
|
||||
and provider_quota_json is not null
|
||||
and (quota_observed_at is null or quota_observed_at <= $3)",
|
||||
|
||||
@@ -173,7 +173,7 @@ async fn core_quota_batch_reads_only_observed_accounts_in_one_contract_call() {
|
||||
}
|
||||
|
||||
#[tokio::test]
|
||||
async fn quota_observation_touch_only_advances_the_refresh_time() {
|
||||
async fn quota_observation_touch_preserves_quota_state_and_advances_account_update_time() {
|
||||
let Some(database) = TestDatabase::create("provider_account_quota_touch").await else {
|
||||
return;
|
||||
};
|
||||
@@ -188,7 +188,7 @@ async fn quota_observation_touch_only_advances_the_refresh_time() {
|
||||
.checked_sub(Duration::from_secs(60))
|
||||
.expect("old observation time");
|
||||
let touched_at = observed_at
|
||||
.checked_add(Duration::from_secs(30))
|
||||
.checked_add(Duration::from_secs(90))
|
||||
.expect("new observation time");
|
||||
let reset_at = observed_at
|
||||
.checked_add(Duration::from_secs(3_600))
|
||||
@@ -272,7 +272,11 @@ async fn quota_observation_touch_only_advances_the_refresh_time() {
|
||||
stored.5.map(|value| value.timestamp_micros()),
|
||||
Some(chrono::DateTime::<Utc>::from(reset_at).timestamp_micros())
|
||||
);
|
||||
assert_eq!(stored.6, account_updated_at);
|
||||
assert_eq!(
|
||||
stored.6.timestamp_micros(),
|
||||
chrono::DateTime::<Utc>::from(touched_at).timestamp_micros()
|
||||
);
|
||||
assert!(stored.6 > account_updated_at);
|
||||
|
||||
database.close().await;
|
||||
}
|
||||
|
||||
@@ -186,7 +186,10 @@ function connectionLogClass(tone: string) {
|
||||
>
|
||||
<span class="font-mono text-cp-muted-text">{{ item.time }}</span>
|
||||
<div class="min-w-0">
|
||||
<p class="m-0 wrap-break-word" :class="connectionLogClass(item.tone)">
|
||||
<p
|
||||
class="m-0 wrap-break-word"
|
||||
:class="connectionLogClass(item.tone)"
|
||||
>
|
||||
{{ item.text }}
|
||||
</p>
|
||||
<div v-if="item.detail" class="mt-2 rounded-lg bg-cp-subtle px-3 py-2">
|
||||
|
||||
@@ -226,13 +226,17 @@ export function useAccountConnectionTest(options: { reload: () => Promise<unknow
|
||||
|
||||
function failConnectionTest(message = '测试连接失败') {
|
||||
if (connectionTestStatus.value === 'running') {
|
||||
connectionTestError.value = message
|
||||
appendConnectionTestLog(connectionTestError.value, 'danger')
|
||||
finishConnectionTest('error')
|
||||
recordConnectionTestFailure('failure', '测试失败', message)
|
||||
}
|
||||
clearConnectionTestRun()
|
||||
}
|
||||
|
||||
function recordConnectionTestFailure(key: string, label: string, message: string) {
|
||||
connectionTestError.value = message
|
||||
setConnectionTestLog(key, label, 'danger', message)
|
||||
finishConnectionTest('error')
|
||||
}
|
||||
|
||||
function handleConnectionTestEvent(event: ConnectionTestEvent) {
|
||||
if (event.type === 'test_start') {
|
||||
connectionTestModel.value = event.model || connectionTestModel.value
|
||||
@@ -261,18 +265,22 @@ export function useAccountConnectionTest(options: { reload: () => Promise<unknow
|
||||
finishConnectionTest('success')
|
||||
}
|
||||
else {
|
||||
connectionTestError.value = connectionTestErrorText(event)
|
||||
appendConnectionTestLog(connectionTestError.value, 'danger')
|
||||
finishConnectionTest('error')
|
||||
recordConnectionTestFailure(
|
||||
'upstream-response',
|
||||
'上游响应',
|
||||
connectionTestErrorText(event),
|
||||
)
|
||||
}
|
||||
clearConnectionTestRun()
|
||||
void options.reload()
|
||||
return
|
||||
}
|
||||
if (event.type === 'error') {
|
||||
connectionTestError.value = connectionTestErrorText(event)
|
||||
appendConnectionTestLog(connectionTestError.value, 'danger')
|
||||
finishConnectionTest('error')
|
||||
recordConnectionTestFailure(
|
||||
'upstream-response',
|
||||
'上游响应',
|
||||
connectionTestErrorText(event),
|
||||
)
|
||||
clearConnectionTestRun()
|
||||
void options.reload()
|
||||
}
|
||||
@@ -381,15 +389,11 @@ export function useAccountConnectionTest(options: { reload: () => Promise<unknow
|
||||
}),
|
||||
)
|
||||
if (connectionTestStatus.value === 'running') {
|
||||
connectionTestError.value = '测试连接未返回完成事件'
|
||||
appendConnectionTestLog(connectionTestError.value, 'danger')
|
||||
finishConnectionTest('error')
|
||||
recordConnectionTestFailure('failure', '测试失败', '测试连接未返回完成事件')
|
||||
}
|
||||
}
|
||||
catch (error: unknown) {
|
||||
connectionTestError.value = errorMessage(error, '测试连接失败')
|
||||
appendConnectionTestLog(connectionTestError.value, 'danger')
|
||||
finishConnectionTest('error')
|
||||
recordConnectionTestFailure('failure', '测试失败', errorMessage(error, '测试连接失败'))
|
||||
}
|
||||
finally {
|
||||
clearConnectionTestRun()
|
||||
|
||||
@@ -109,7 +109,7 @@ function diagnosticNameDisplay(name: string) {
|
||||
as="article"
|
||||
title="热点诊断"
|
||||
:description="`按${selectedDimensionLabel}定位错误、慢请求与费用热点`"
|
||||
class="h-105 min-h-105 max-h-105 min-w-0 w-full lg:h-90 lg:min-h-90 lg:max-h-90"
|
||||
class="h-105 min-h-105 max-h-105 min-w-0 w-full lg:h-full lg:min-h-90 lg:max-h-105"
|
||||
>
|
||||
<template #actions>
|
||||
<BaseSegmented
|
||||
@@ -125,7 +125,7 @@ function diagnosticNameDisplay(name: string) {
|
||||
<BaseTable
|
||||
v-if="hasData"
|
||||
:key="resultDimension"
|
||||
class="min-h-0 w-full"
|
||||
class="min-h-0 w-full xl:contain-[size]"
|
||||
:columns="diagnosticColumns"
|
||||
:rows="displayItems"
|
||||
density="compact"
|
||||
|
||||
@@ -1 +1 @@
|
||||
version: "3.2.10"
|
||||
version: "3.2.11"
|
||||
|
||||
Reference in New Issue
Block a user