@@ -540,7 +540,7 @@ async def get_agent_analytics(
540540 or 0
541541 )
542542
543- satisfaction_rate = round ((positive_feedbacks / total_feedbacks * 100 ), 2 ) if total_feedbacks > 0 else 0
543+ satisfaction_rate = round ((positive_feedbacks / total_feedbacks * 100 ), 2 ) if total_feedbacks > 0 else 100
544544
545545 agent_satisfaction .append (
546546 {"agent_id" : agent_id , "satisfaction_rate" : satisfaction_rate , "total_feedbacks" : total_feedbacks }
@@ -624,7 +624,7 @@ async def get_dashboard_stats(
624624 like_count = db .query (func .count (MessageFeedback .id )).filter (MessageFeedback .rating == "like" ).scalar () or 0
625625
626626 # Calculate satisfaction rate
627- satisfaction_rate = round ((like_count / total_feedbacks * 100 ), 2 ) if total_feedbacks > 0 else 0
627+ satisfaction_rate = round ((like_count / total_feedbacks * 100 ), 2 ) if total_feedbacks > 0 else 100
628628
629629 return {
630630 "total_conversations" : total_conversations ,
@@ -738,7 +738,7 @@ class TimeSeriesStats(BaseModel):
738738@dashboard .get ("/stats/calls/timeseries" , response_model = TimeSeriesStats )
739739async def get_call_timeseries_stats (
740740 type : str = "models" , # models/agents/tokens/tools
741- time_range : str = "7days " , # 7hours/7days/7weeks
741+ time_range : str = "14days " , # 14hours/14days/14weeks
742742 db : Session = Depends (get_db ),
743743 current_user : User = Depends (get_admin_user ),
744744):
@@ -750,24 +750,24 @@ async def get_call_timeseries_stats(
750750 now = utc_now ()
751751 local_now = shanghai_now ()
752752
753- if time_range == "7hours " :
754- intervals = 7
755- # 包含当前小时:从6小时前开始
753+ if time_range == "14hours " :
754+ intervals = 14
755+ # 包含当前小时:从13小时前开始
756756 start_time = now - timedelta (hours = intervals - 1 )
757757 group_format = func .strftime ("%Y-%m-%d %H:00" , func .datetime (Message .created_at , "+8 hours" ))
758758 base_local_time = ensure_shanghai (start_time )
759- elif time_range == "7weeks " :
760- intervals = 7
761- # 包含当前周:从6周前开始 ,并对齐到当周周一 00:00
759+ elif time_range == "14weeks " :
760+ intervals = 14
761+ # 包含当前周:从13周前开始 ,并对齐到当周周一 00:00
762762 local_start = local_now - timedelta (weeks = intervals - 1 )
763763 local_start = local_start - timedelta (days = local_start .weekday ())
764764 local_start = local_start .replace (hour = 0 , minute = 0 , second = 0 , microsecond = 0 )
765765 start_time = local_start .astimezone (UTC )
766766 group_format = func .strftime ("%Y-%W" , func .datetime (Message .created_at , "+8 hours" ))
767767 base_local_time = local_start
768- else : # 7days (default)
769- intervals = 7
770- # 包含当前天:从6天前开始
768+ else : # 14days (default)
769+ intervals = 14
770+ # 包含当前天:从13天前开始
771771 start_time = now - timedelta (days = intervals - 1 )
772772 group_format = func .strftime ("%Y-%m-%d" , func .datetime (Message .created_at , "+8 hours" ))
773773 base_local_time = ensure_shanghai (start_time )
@@ -790,11 +790,11 @@ async def get_call_timeseries_stats(
790790 elif type == "agents" :
791791 # 智能体调用统计(基于对话更新时间,按智能体分组)
792792 # 为对话创建独立的时间格式化器
793- if time_range == "7hours " :
793+ if time_range == "14hours " :
794794 conv_group_format = func .strftime ("%Y-%m-%d %H:00" , func .datetime (Conversation .updated_at , "+8 hours" ))
795- elif time_range == "7weeks " :
795+ elif time_range == "14weeks " :
796796 conv_group_format = func .strftime ("%Y-%W" , func .datetime (Conversation .updated_at , "+8 hours" ))
797- else : # 7days
797+ else : # 14days
798798 conv_group_format = func .strftime ("%Y-%m-%d" , func .datetime (Conversation .updated_at , "+8 hours" ))
799799
800800 query = (
@@ -855,11 +855,11 @@ async def get_call_timeseries_stats(
855855 elif type == "tools" :
856856 # 工具调用统计(按工具名称分组)
857857 # 为工具调用创建独立的时间格式化器
858- if time_range == "7hours " :
858+ if time_range == "14hours " :
859859 tool_group_format = func .strftime ("%Y-%m-%d %H:00" , func .datetime (ToolCall .created_at , "+8 hours" ))
860- elif time_range == "7weeks " :
860+ elif time_range == "14weeks " :
861861 tool_group_format = func .strftime ("%Y-%W" , func .datetime (ToolCall .created_at , "+8 hours" ))
862- else : # 7days
862+ else : # 14days
863863 tool_group_format = func .strftime ("%Y-%m-%d" , func .datetime (ToolCall .created_at , "+8 hours" ))
864864
865865 query = (
@@ -908,7 +908,7 @@ def normalize_week_key(raw_key: str) -> str:
908908
909909 for result in results :
910910 date_key = result .date
911- if time_range == "7weeks " :
911+ if time_range == "14weeks " :
912912 date_key = normalize_week_key (date_key )
913913 category = getattr (result , "category" , "unknown" )
914914 count = result .count
@@ -923,17 +923,17 @@ def normalize_week_key(raw_key: str) -> str:
923923 # 从起始点开始(北京时间)
924924 current_time = base_local_time
925925
926- if time_range == "7hours " :
926+ if time_range == "14hours " :
927927 delta = timedelta (hours = 1 )
928- elif time_range == "7weeks " :
928+ elif time_range == "14weeks " :
929929 delta = timedelta (weeks = 1 )
930930 else :
931931 delta = timedelta (days = 1 )
932932
933933 for i in range (intervals ):
934- if time_range == "7hours " :
934+ if time_range == "14hours " :
935935 date_key = current_time .strftime ("%Y-%m-%d %H:00" )
936- elif time_range == "7weeks " :
936+ elif time_range == "14weeks " :
937937 iso_year , iso_week , _ = current_time .isocalendar ()
938938 date_key = f"{ iso_year } -{ iso_week :02d} "
939939 else :
0 commit comments