mirror of
https://gitee.com/wanwujie/sub2api
synced 2026-04-19 14:24:45 +08:00
fix: stabilize repository integration paths
This commit is contained in:
@@ -30,6 +30,45 @@ import (
|
||||
|
||||
const usageLogSelectColumns = "id, user_id, api_key_id, account_id, request_id, model, group_id, subscription_id, input_tokens, output_tokens, cache_creation_tokens, cache_read_tokens, cache_creation_5m_tokens, cache_creation_1h_tokens, input_cost, output_cost, cache_creation_cost, cache_read_cost, total_cost, actual_cost, rate_multiplier, account_rate_multiplier, billing_type, request_type, stream, openai_ws_mode, duration_ms, first_token_ms, user_agent, ip_address, image_count, image_size, media_type, service_tier, reasoning_effort, cache_ttl_overridden, created_at"
|
||||
|
||||
var usageLogInsertArgTypes = [...]string{
|
||||
"bigint",
|
||||
"bigint",
|
||||
"bigint",
|
||||
"text",
|
||||
"text",
|
||||
"bigint",
|
||||
"bigint",
|
||||
"integer",
|
||||
"integer",
|
||||
"integer",
|
||||
"integer",
|
||||
"integer",
|
||||
"integer",
|
||||
"numeric",
|
||||
"numeric",
|
||||
"numeric",
|
||||
"numeric",
|
||||
"numeric",
|
||||
"numeric",
|
||||
"numeric",
|
||||
"numeric",
|
||||
"smallint",
|
||||
"smallint",
|
||||
"boolean",
|
||||
"boolean",
|
||||
"integer",
|
||||
"integer",
|
||||
"text",
|
||||
"text",
|
||||
"integer",
|
||||
"text",
|
||||
"text",
|
||||
"text",
|
||||
"text",
|
||||
"boolean",
|
||||
"timestamptz",
|
||||
}
|
||||
|
||||
// dateFormatWhitelist 将 granularity 参数映射为 PostgreSQL TO_CHAR 格式字符串,防止外部输入直接拼入 SQL
|
||||
var dateFormatWhitelist = map[string]string{
|
||||
"hour": "YYYY-MM-DD HH24:00",
|
||||
@@ -713,6 +752,10 @@ func buildUsageLogBatchInsertQuery(keys []string, preparedByKey map[string]usage
|
||||
_, _ = query.WriteString(",")
|
||||
_, _ = query.WriteString("$")
|
||||
_, _ = query.WriteString(strconv.Itoa(argPos))
|
||||
if i < len(usageLogInsertArgTypes) {
|
||||
_, _ = query.WriteString("::")
|
||||
_, _ = query.WriteString(usageLogInsertArgTypes[i])
|
||||
}
|
||||
argPos++
|
||||
}
|
||||
_, _ = query.WriteString(")")
|
||||
@@ -877,6 +920,10 @@ func buildUsageLogBestEffortInsertQuery(preparedList []usageLogInsertPrepared) (
|
||||
}
|
||||
_, _ = query.WriteString("$")
|
||||
_, _ = query.WriteString(strconv.Itoa(argPos))
|
||||
if i < len(usageLogInsertArgTypes) {
|
||||
_, _ = query.WriteString("::")
|
||||
_, _ = query.WriteString(usageLogInsertArgTypes[i])
|
||||
}
|
||||
argPos++
|
||||
}
|
||||
_, _ = query.WriteString(")")
|
||||
|
||||
Reference in New Issue
Block a user