feat(message_summary): add group overview stats section

This commit is contained in:
liuwei
2026-04-13 09:18:44 +08:00
parent 0e3eda8865
commit 0f0acc1729
3 changed files with 95 additions and 3 deletions

View File

@@ -551,6 +551,27 @@ class MessageStorage:
logger.error(f"统计消息数量出错: {e}")
return 0
def get_message_stats_by_date_range(self, group_id, start_time: datetime, end_time: datetime) -> Dict:
"""获取指定时间范围内的群消息概览统计"""
try:
stats = self.message_db.get_message_stats_by_date_range(group_id, start_time, end_time)
logger.info(
f"{group_id}{start_time}{end_time} 的消息概览: "
f"total={stats.get('total_count', 0)}, participants={stats.get('participant_count', 0)}"
)
return stats
except Exception as e:
logger.error(f"获取消息概览统计出错: {e}")
return {
"total_count": 0,
"participant_count": 0,
"text_count": 0,
"image_count": 0,
"video_count": 0,
"link_count": 0,
"emoji_count": 0,
}
def _format_messages_optimized(self, messages: list, all_contacts: dict) -> str:
"""优化的消息格式化方法,减少冗余