refactor(rust): 拆分 usage sql 仓储为模块并外置 SQL 文件

- 将 usage/sql.rs 拆分为 sql/mod.rs 与 sql/tests.rs
- 将内联 SQL 抽离到 sql/queries/ 目录下的独立 .sql 文件
- 前端用量记录表格移除缓存创建 token 展示,保留 cache read 列
This commit is contained in:
fawney19
2026-04-24 20:22:24 +08:00
parent d0d71aa51a
commit 657fcd595c
26 changed files with 3127 additions and 3161 deletions

View File

@@ -569,9 +569,9 @@
<span>{{ formatTokens(record.output_tokens || 0) }}</span>
</div>
<div class="flex items-center gap-1 text-muted-foreground">
<span :class="hasPositiveTokens(getRecordCacheCreationTokens(record)) ? 'text-foreground/70' : ''">{{ formatOptionalTokens(getRecordCacheCreationTokens(record)) }}</span>
<span>/</span>
<span :class="hasPositiveTokens(record.cache_read_input_tokens) ? 'text-foreground/70' : ''">{{ formatOptionalTokens(record.cache_read_input_tokens) }}</span>
<span>/</span>
<span>-</span>
</div>
</div>
</TableCell>
@@ -689,7 +689,7 @@ import {
import { RefreshCcw, Search } from 'lucide-vue-next'
import { formatTokens, formatCurrency } from '@/utils/format'
import { formatDateTime } from '../composables'
import { getCacheCreationTokens, getEffectiveInputTokens } from '../token-normalization'
import { getEffectiveInputTokens } from '../token-normalization'
import {
formatUsageStreamLabel,
isUsageRecordFailed,
@@ -825,10 +825,6 @@ function getRecordEffectiveInputTokens(record: UsageRecord): number {
return getEffectiveInputTokens(record)
}
function getRecordCacheCreationTokens(record: UsageRecord): number {
return getCacheCreationTokens(record)
}
function hasPositiveTokens(value: number | null | undefined): boolean {
return typeof value === 'number' && Number.isFinite(value) && value > 0
}