You've already forked agentic-coding-workflow
55 lines
1.7 KiB
Go
55 lines
1.7 KiB
Go
// Code generated by sqlc. DO NOT EDIT.
|
|
// versions:
|
|
// sqlc v1.31.1
|
|
// source: session_usage.sql
|
|
|
|
package acpsqlc
|
|
|
|
import (
|
|
"context"
|
|
|
|
"github.com/jackc/pgx/v5/pgtype"
|
|
)
|
|
|
|
const insertSessionUsage = `-- name: InsertSessionUsage :one
|
|
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
|
|
`
|
|
|
|
type InsertSessionUsageParams struct {
|
|
SessionID pgtype.UUID `json:"session_id"`
|
|
UserID pgtype.UUID `json:"user_id"`
|
|
ProjectID pgtype.UUID `json:"project_id"`
|
|
AgentKindID pgtype.UUID `json:"agent_kind_id"`
|
|
ModelID pgtype.UUID `json:"model_id"`
|
|
PromptTokens int64 `json:"prompt_tokens"`
|
|
CompletionTokens int64 `json:"completion_tokens"`
|
|
ThinkingTokens int64 `json:"thinking_tokens"`
|
|
CostUsd pgtype.Numeric `json:"cost_usd"`
|
|
SourceEventID *int64 `json:"source_event_id"`
|
|
}
|
|
|
|
// 写一条 per-turn 用量账目。source_event_id 非空时按唯一索引去重(同一事件
|
|
// 重复 Observe 不会重复入账);返回受影响行数判定是否实际插入。
|
|
func (q *Queries) InsertSessionUsage(ctx context.Context, arg InsertSessionUsageParams) (int64, error) {
|
|
row := q.db.QueryRow(ctx, insertSessionUsage,
|
|
arg.SessionID,
|
|
arg.UserID,
|
|
arg.ProjectID,
|
|
arg.AgentKindID,
|
|
arg.ModelID,
|
|
arg.PromptTokens,
|
|
arg.CompletionTokens,
|
|
arg.ThinkingTokens,
|
|
arg.CostUsd,
|
|
arg.SourceEventID,
|
|
)
|
|
var id int64
|
|
err := row.Scan(&id)
|
|
return id, err
|
|
}
|