You've already forked agentic-coding-workflow
10 lines
534 B
SQL
10 lines
534 B
SQL
-- name: InsertSessionUsage :one
|
|
-- 写一条 per-turn 用量账目。source_event_id 非空时按唯一索引去重(同一事件
|
|
-- 重复 Observe 不会重复入账);返回受影响行数判定是否实际插入。
|
|
INSERT INTO acp_session_usage (
|
|
session_id, user_id, project_id, agent_kind_id, model_id,
|
|
prompt_tokens, completion_tokens, thinking_tokens, cost_usd, source_event_id
|
|
) VALUES ($1, $2, $3, $4, $5, $6, $7, $8, $9, $10)
|
|
ON CONFLICT (source_event_id) WHERE source_event_id IS NOT NULL DO NOTHING
|
|
RETURNING id;
|