@@ -120,9 +120,6 @@ def user_breakdown
120120 :user_id ,
121121 "users.username" ,
122122 "users.uploaded_avatar_id" ,
123- "llm_models.input_cost" ,
124- "llm_models.output_cost" ,
125- "llm_models.cached_input_cost" ,
126123 )
127124 . order ( "usage_count DESC" )
128125 . limit ( USER_LIMIT )
@@ -134,20 +131,17 @@ def user_breakdown
134131 "SUM(COALESCE(cached_tokens,0)) as total_cached_tokens" ,
135132 "SUM(COALESCE(request_tokens,0)) as total_request_tokens" ,
136133 "SUM(COALESCE(response_tokens,0)) as total_response_tokens" ,
137- "SUM(COALESCE(request_tokens, 0)) * COALESCE(llm_models.input_cost, 0) / 1000000.0 as input_spending" ,
138- "SUM(COALESCE(response_tokens, 0)) * COALESCE(llm_models.output_cost, 0) / 1000000.0 as output_spending" ,
139- "SUM(COALESCE(cached_tokens, 0)) * COALESCE(llm_models.cached_input_cost, 0) / 1000000.0 as cached_input_spending" ,
134+ "SUM(COALESCE(request_tokens, 0) * COALESCE(llm_models.input_cost, 0) ) / 1000000.0 as input_spending" ,
135+ "SUM(COALESCE(response_tokens, 0) * COALESCE(llm_models.output_cost, 0) ) / 1000000.0 as output_spending" ,
136+ "SUM(COALESCE(cached_tokens, 0) * COALESCE(llm_models.cached_input_cost, 0) ) / 1000000.0 as cached_input_spending" ,
140137 )
141138 end
142139
143140 def feature_breakdown
144141 base_query
145142 . joins ( "LEFT JOIN llm_models ON llm_models.name = language_model" )
146143 . group (
147- :feature_name ,
148- "llm_models.input_cost" ,
149- "llm_models.output_cost" ,
150- "llm_models.cached_input_cost" ,
144+ :feature_name
151145 )
152146 . order ( "usage_count DESC" )
153147 . select (
@@ -157,9 +151,9 @@ def feature_breakdown
157151 "SUM(COALESCE(cached_tokens,0)) as total_cached_tokens" ,
158152 "SUM(COALESCE(request_tokens,0)) as total_request_tokens" ,
159153 "SUM(COALESCE(response_tokens,0)) as total_response_tokens" ,
160- "SUM(COALESCE(request_tokens, 0)) * COALESCE(llm_models.input_cost, 0) / 1000000.0 as input_spending" ,
161- "SUM(COALESCE(response_tokens, 0)) * COALESCE(llm_models.output_cost, 0) / 1000000.0 as output_spending" ,
162- "SUM(COALESCE(cached_tokens, 0)) * COALESCE(llm_models.cached_input_cost, 0) / 1000000.0 as cached_input_spending" ,
154+ "SUM(COALESCE(request_tokens, 0) * COALESCE(llm_models.input_cost, 0)) / 1000000.0 as input_spending" ,
155+ "SUM(COALESCE(response_tokens, 0) * COALESCE(llm_models.output_cost, 0) ) / 1000000.0 as output_spending" ,
156+ "SUM(COALESCE(cached_tokens, 0) * COALESCE(llm_models.cached_input_cost, 0) ) / 1000000.0 as cached_input_spending" ,
163157 )
164158 end
165159
0 commit comments