fix(usage): 完善 cache-affinity 时间线的用户名回退与模型空值兜底

- 当 auth 用户查询失败时回退到历史 username,避免时间线丢失用户信息
- SQL 投影对 usage.model 使用 COALESCE 兜底空值
- IntervalTimelineCard 在刷新间隔为 0 时跳过定时刷新
- Usage 页面关闭时间线卡片的自动轮询
This commit is contained in:
fawney19
2026-04-19 16:07:01 +08:00
parent 41b51f10a9
commit c302dfe42d
5 changed files with 107 additions and 6 deletions

View File

@@ -2495,7 +2495,7 @@ WITH filtered_usage AS (
builder.push(
r#" AS group_id,
"usage".username AS username,
"usage".model AS model,
COALESCE("usage".model, '') AS model,
"usage".created_at AS created_at,
"usage".id AS usage_id
FROM "usage"
@@ -6188,6 +6188,11 @@ mod tests {
assert!(super::LIST_RECENT_USAGE_AUDITS_PREFIX.contains("FROM \"usage\""));
}
#[test]
fn usage_sql_cache_affinity_interval_query_coalesces_nullable_model_values() {
assert!(include_str!("sql.rs").contains("COALESCE(\"usage\".model, '') AS model"));
}
#[test]
fn usage_sql_reads_http_audits_for_single_record_fetches() {
assert!(super::FIND_BY_REQUEST_ID_SQL.contains("LEFT JOIN usage_http_audits"));