fix(usage): filter control messages and repair unknown records
- filter empty, null, refresh, and support_refresh messages before persistence - require request_id for usage records - repair Claude cache token accounting - delete historical unknown records - show deleted record count in usage management
This commit is contained in:
1 parent
3ebca59535
commit
cbd82386d5
4 files changed
+200
-30
No files matched your search
@@ -248,18 +248,19 @@ export const en: Record<MessageKey, string> = {
|
||||
'usage.pricing.deleted': 'Model price deleted; overview cost updated',
|
||||
'usage.pricing.deleteConfirm': 'Delete the price for {model}?',
|
||||
'usage.dataManagement.title': 'Historical Data Management',
|
||||
'usage.dataManagement.description': 'Scan and repair historical usage records with inconsistent cache token accounting.',
|
||||
'usage.dataManagement.description': 'Scan and repair known anomalies in historical usage records.',
|
||||
'usage.dataManagement.manualBadge': 'Manual action',
|
||||
'usage.dataManagement.notice': 'A database backup is created first. Only identifiable Claude / Anthropic records are processed.',
|
||||
'usage.dataManagement.actionTitle': 'Repair cache records',
|
||||
'usage.dataManagement.actionDescription': 'Use input token accounting that includes cache reads and cache creation.',
|
||||
'usage.dataManagement.notice': 'A database backup is created first. Only cache anomalies and unknown records are processed.',
|
||||
'usage.dataManagement.actionTitle': 'Repair historical anomalies',
|
||||
'usage.dataManagement.actionDescription': 'Correct Claude cache token accounting and delete records recorded as unknown usage.',
|
||||
'usage.dataManagement.run': 'Scan and repair',
|
||||
'usage.dataManagement.running': 'Processing…',
|
||||
'usage.dataManagement.confirm': 'Scan and repair historical cache records? A database backup will be created first.',
|
||||
'usage.dataManagement.confirm': 'Scan and repair historical anomalous records? A database backup will be created first.',
|
||||
'usage.dataManagement.scanned': 'Scanned',
|
||||
'usage.dataManagement.repaired': 'Repaired',
|
||||
'usage.dataManagement.deleted': 'Invalid records deleted',
|
||||
'usage.dataManagement.backup': 'Backup file',
|
||||
'usage.dataManagement.success': 'Historical cache data processing completed. {repaired} records repaired.',
|
||||
'usage.dataManagement.success': 'Historical data processed: {repaired} repaired and {deleted} invalid records deleted.',
|
||||
'usage.trend.title': 'Request and Token Trend',
|
||||
'usage.trend.description': 'Grouped by local system hour',
|
||||
'usage.token.title': 'Token Breakdown',
|
||||
|
||||
@@ -246,18 +246,19 @@ export const zhCN = {
|
||||
'usage.pricing.deleted': '模型价格已删除,总览成本已更新',
|
||||
'usage.pricing.deleteConfirm': '确定删除模型 {model} 的价格吗?',
|
||||
'usage.dataManagement.title': '历史数据管理',
|
||||
'usage.dataManagement.description': '扫描并修复缓存 Token 口径异常的历史使用记录。',
|
||||
'usage.dataManagement.description': '扫描并修复历史使用记录中的已知数据异常。',
|
||||
'usage.dataManagement.manualBadge': '手动操作',
|
||||
'usage.dataManagement.notice': '修复前会自动备份数据库,仅处理可确认的 Claude / Anthropic 异常记录。',
|
||||
'usage.dataManagement.actionTitle': '修复异常缓存记录',
|
||||
'usage.dataManagement.actionDescription': '将输入 Token 统一为包含缓存读取和缓存创建的统计口径。',
|
||||
'usage.dataManagement.notice': '修复前会自动备份数据库,仅处理缓存口径异常和 unknown 记录。',
|
||||
'usage.dataManagement.actionTitle': '修复历史异常记录',
|
||||
'usage.dataManagement.actionDescription': '修正错误缓存信息,并删除被误记为 unknown 的记录。',
|
||||
'usage.dataManagement.run': '扫描并修复',
|
||||
'usage.dataManagement.running': '处理中…',
|
||||
'usage.dataManagement.confirm': '确定扫描并修复历史缓存记录吗?修复前会自动创建数据库备份。',
|
||||
'usage.dataManagement.confirm': '确定扫描并修复历史异常记录吗?修复前会自动创建数据库备份。',
|
||||
'usage.dataManagement.scanned': '扫描记录',
|
||||
'usage.dataManagement.repaired': '修复记录',
|
||||
'usage.dataManagement.deleted': '删除误记录',
|
||||
'usage.dataManagement.backup': '备份文件',
|
||||
'usage.dataManagement.success': '历史缓存数据处理完成,已修复 {repaired} 条记录。',
|
||||
'usage.dataManagement.success': '历史数据处理完成:修复 {repaired} 条,删除 {deleted} 条误记录。',
|
||||
'usage.trend.title': '请求与 Token 趋势',
|
||||
'usage.trend.description': '按系统本地小时聚合',
|
||||
'usage.token.title': 'Token 构成',
|
||||
|
||||
@@ -163,6 +163,7 @@ type UsagePricing = {
|
||||
type UsageRepairResult = {
|
||||
scanned: number;
|
||||
repaired: number;
|
||||
deleted: number;
|
||||
backupPath: string | null;
|
||||
};
|
||||
|
||||
@@ -759,11 +760,12 @@ function UsageDataManagementView() {
|
||||
<>
|
||||
<div className="management-alert success">
|
||||
<ShieldCheck size={16} aria-hidden="true" />
|
||||
<span>{t('usage.dataManagement.success', { repaired: result.repaired })}</span>
|
||||
<span>{t('usage.dataManagement.success', { repaired: result.repaired, deleted: result.deleted })}</span>
|
||||
</div>
|
||||
<div className="usage-data-management-result">
|
||||
<div><span>{t('usage.dataManagement.scanned')}</span><strong>{result.scanned.toLocaleString()}</strong></div>
|
||||
<div><span>{t('usage.dataManagement.repaired')}</span><strong>{result.repaired.toLocaleString()}</strong></div>
|
||||
<div><span>{t('usage.dataManagement.deleted')}</span><strong>{result.deleted.toLocaleString()}</strong></div>
|
||||
<div><span>{t('usage.dataManagement.backup')}</span><strong title={result.backupPath ?? undefined}>{result.backupPath ?? '—'}</strong></div>
|
||||
</div>
|
||||
</>
|
||||
|
||||
Reference in new issue
Block a user