@@ -289,11 +289,9 @@ def aggregation(self, auth, with_valid=True):
289289 auth , data ["user_id" ], data .get ("workspace_id" )
290290 ),
291291 )
292- return {
293- "total_tokens" : query .aggregate (
294- total_tokens = Coalesce (Sum (F ("message_tokens" ) + F ("answer_tokens" ), output_field = IntegerField ()), 0 )
295- )["total_tokens" ]
296- }
292+ return query .aggregate (
293+ total_tokens = Coalesce (Sum (F ("message_tokens" ) + F ("answer_tokens" ), output_field = IntegerField ()), 0 )
294+ )["total_tokens" ]
297295
298296 class ChatRecordAggregation (serializers .Serializer ):
299297 workspace_id = serializers .CharField (required = False , allow_null = True , label = _ ("Workspace ID" ))
@@ -312,7 +310,7 @@ def aggregation(self, auth, with_valid=True):
312310 auth , data ["user_id" ], data .get ("workspace_id" )
313311 ),
314312 )
315- return {"total_count" : query .aggregate (total_count = Count ("id" ))["total_count" ]}
313+ return {query .aggregate (total_count = Count ("id" ))["total_count" ]}
316314
317315 class ApplicationTokensRanking (serializers .Serializer ):
318316 workspace_id = serializers .CharField (required = False , allow_null = True , label = _ ("Workspace ID" ))
@@ -371,7 +369,7 @@ def ranking(self, auth, current_page, page_size, with_valid=True):
371369 def export (self , auth , with_valid = True ):
372370 if with_valid :
373371 self .is_valid (raise_exception = True )
374- tokens_total = SystemHomePageSerializer .TokensAggregation (data = self .data ).aggregation (auth )[ "total_tokens" ]
372+ tokens_total = SystemHomePageSerializer .TokensAggregation (data = self .data ).aggregation (auth )
375373 queryset = self .get_queryset (auth , with_valid = False )
376374 workbook = openpyxl .Workbook (write_only = True )
377375 worksheet = workbook .create_sheet (title = "Sheet1" )
@@ -561,7 +559,7 @@ def ranking(self, auth, current_page, page_size, with_valid=True):
561559 def export (self , auth , with_valid = True ):
562560 if with_valid :
563561 self .is_valid (raise_exception = True )
564- token_count = SystemHomePageSerializer .TokensAggregation (data = self .data ).aggregation (auth )[ "total_tokens" ]
562+ token_count = SystemHomePageSerializer .TokensAggregation (data = self .data ).aggregation (auth )
565563 queryset , asker_map = self .get_queryset (auth , with_valid = False )
566564 workbook = openpyxl .Workbook (write_only = True )
567565 worksheet = workbook .create_sheet (title = "Sheet1" )
0 commit comments