fix: remove media_type from usage_log SQL queries + gofmt + inline test helpers
This commit is contained in:
@@ -28,7 +28,7 @@ import (
|
|||||||
gocache "github.com/patrickmn/go-cache"
|
gocache "github.com/patrickmn/go-cache"
|
||||||
)
|
)
|
||||||
|
|
||||||
const usageLogSelectColumns = "id, user_id, api_key_id, account_id, request_id, model, requested_model, upstream_model, group_id, subscription_id, input_tokens, output_tokens, cache_creation_tokens, cache_read_tokens, cache_creation_5m_tokens, cache_creation_1h_tokens, image_output_tokens, image_output_cost, 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, inbound_endpoint, upstream_endpoint, cache_ttl_overridden, channel_id, model_mapping_chain, billing_tier, billing_mode, created_at"
|
const usageLogSelectColumns = "id, user_id, api_key_id, account_id, request_id, model, requested_model, upstream_model, group_id, subscription_id, input_tokens, output_tokens, cache_creation_tokens, cache_read_tokens, cache_creation_5m_tokens, cache_creation_1h_tokens, image_output_tokens, image_output_cost, 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, service_tier, reasoning_effort, inbound_endpoint, upstream_endpoint, cache_ttl_overridden, channel_id, model_mapping_chain, billing_tier, billing_mode, created_at"
|
||||||
|
|
||||||
// usageLogInsertArgTypes must stay in the same order as:
|
// usageLogInsertArgTypes must stay in the same order as:
|
||||||
// 1. prepareUsageLogInsert().args
|
// 1. prepareUsageLogInsert().args
|
||||||
@@ -73,7 +73,6 @@ var usageLogInsertArgTypes = [...]string{
|
|||||||
"text", // ip_address
|
"text", // ip_address
|
||||||
"integer", // image_count
|
"integer", // image_count
|
||||||
"text", // image_size
|
"text", // image_size
|
||||||
"text", // media_type
|
|
||||||
"text", // service_tier
|
"text", // service_tier
|
||||||
"text", // reasoning_effort
|
"text", // reasoning_effort
|
||||||
"text", // inbound_endpoint
|
"text", // inbound_endpoint
|
||||||
@@ -352,7 +351,6 @@ func (r *usageLogRepository) createSingle(ctx context.Context, sqlq sqlExecutor,
|
|||||||
ip_address,
|
ip_address,
|
||||||
image_count,
|
image_count,
|
||||||
image_size,
|
image_size,
|
||||||
media_type,
|
|
||||||
service_tier,
|
service_tier,
|
||||||
reasoning_effort,
|
reasoning_effort,
|
||||||
inbound_endpoint,
|
inbound_endpoint,
|
||||||
@@ -369,7 +367,7 @@ func (r *usageLogRepository) createSingle(ctx context.Context, sqlq sqlExecutor,
|
|||||||
$10, $11, $12, $13,
|
$10, $11, $12, $13,
|
||||||
$14, $15, $16, $17,
|
$14, $15, $16, $17,
|
||||||
$18, $19, $20, $21, $22, $23,
|
$18, $19, $20, $21, $22, $23,
|
||||||
$24, $25, $26, $27, $28, $29, $30, $31, $32, $33, $34, $35, $36, $37, $38, $39, $40, $41, $42, $43, $44, $45, $46
|
$24, $25, $26, $27, $28, $29, $30, $31, $32, $33, $34, $35, $36, $37, $38, $39, $40, $41, $42, $43, $44, $45
|
||||||
)
|
)
|
||||||
ON CONFLICT (request_id, api_key_id) DO NOTHING
|
ON CONFLICT (request_id, api_key_id) DO NOTHING
|
||||||
RETURNING id, created_at
|
RETURNING id, created_at
|
||||||
@@ -790,7 +788,6 @@ func buildUsageLogBatchInsertQuery(keys []string, preparedByKey map[string]usage
|
|||||||
ip_address,
|
ip_address,
|
||||||
image_count,
|
image_count,
|
||||||
image_size,
|
image_size,
|
||||||
media_type,
|
|
||||||
service_tier,
|
service_tier,
|
||||||
reasoning_effort,
|
reasoning_effort,
|
||||||
inbound_endpoint,
|
inbound_endpoint,
|
||||||
@@ -1003,7 +1000,6 @@ func buildUsageLogBestEffortInsertQuery(preparedList []usageLogInsertPrepared) (
|
|||||||
ip_address,
|
ip_address,
|
||||||
image_count,
|
image_count,
|
||||||
image_size,
|
image_size,
|
||||||
media_type,
|
|
||||||
service_tier,
|
service_tier,
|
||||||
reasoning_effort,
|
reasoning_effort,
|
||||||
inbound_endpoint,
|
inbound_endpoint,
|
||||||
@@ -1077,7 +1073,6 @@ func buildUsageLogBestEffortInsertQuery(preparedList []usageLogInsertPrepared) (
|
|||||||
ip_address,
|
ip_address,
|
||||||
image_count,
|
image_count,
|
||||||
image_size,
|
image_size,
|
||||||
media_type,
|
|
||||||
service_tier,
|
service_tier,
|
||||||
reasoning_effort,
|
reasoning_effort,
|
||||||
inbound_endpoint,
|
inbound_endpoint,
|
||||||
@@ -1125,7 +1120,6 @@ func buildUsageLogBestEffortInsertQuery(preparedList []usageLogInsertPrepared) (
|
|||||||
ip_address,
|
ip_address,
|
||||||
image_count,
|
image_count,
|
||||||
image_size,
|
image_size,
|
||||||
media_type,
|
|
||||||
service_tier,
|
service_tier,
|
||||||
reasoning_effort,
|
reasoning_effort,
|
||||||
inbound_endpoint,
|
inbound_endpoint,
|
||||||
@@ -1181,7 +1175,6 @@ func execUsageLogInsertNoResult(ctx context.Context, sqlq sqlExecutor, prepared
|
|||||||
ip_address,
|
ip_address,
|
||||||
image_count,
|
image_count,
|
||||||
image_size,
|
image_size,
|
||||||
media_type,
|
|
||||||
service_tier,
|
service_tier,
|
||||||
reasoning_effort,
|
reasoning_effort,
|
||||||
inbound_endpoint,
|
inbound_endpoint,
|
||||||
|
|||||||
Reference in New Issue
Block a user