Skip to content

Commit

Permalink
fix: typo
Browse files Browse the repository at this point in the history
  • Loading branch information
RaoHai committed Sep 12, 2024
1 parent f6644a6 commit f43b220
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 3 deletions.
Original file line number Diff line number Diff line change
@@ -1,15 +1,15 @@
set check_function_bodies = off;

CREATE OR REPLACE FUNCTION public.get_user_stats(filter_user_id text, start_date date, end_date date)
RETURNS TABLE(usage_date date, input_tokens bigint, output_tokes bigint, total_tokens bigint)
RETURNS TABLE(usage_date date, input_tokens bigint, output_tokens bigint, total_tokens bigint)
LANGUAGE plpgsql
AS $function$
BEGIN
RETURN QUERY
SELECT
u.date AS usage_date, -- 使用别名来避免歧义
SUM(u.input_token)::BIGINT AS input_tokens, -- 将结果转换为 BIGINT
SUM(u.output_token)::BIGINT AS output_tokes, -- 将结果转换为 BIGINT
SUM(u.output_token)::BIGINT AS output_tokens, -- 将结果转换为 BIGINT
SUM(u.total_token)::BIGINT AS total_tokens -- 将结果转换为 BIGINT
FROM user_token_usage u
WHERE u.user_id = filter_user_id -- 使用别名来引用参数
Expand Down
2 changes: 1 addition & 1 deletion server/core/models/user_token_usage.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,5 +17,5 @@ class UserTokenUsage(BaseModel):
class UserTokenUsageStats(BaseModel):
usage_date: datetime
input_tokens: Optional[int] = 0
output_tokes: Optional[int] = 0
output_tokens: Optional[int] = 0
total_tokens: Optional[int] = 0

0 comments on commit f43b220

Please sign in to comment.