dashboard部分添加最近一周、模型使用统计数据

This commit is contained in:
junleea 2025-04-06 15:07:35 +08:00
parent 210daec992
commit d5ae2cb902
2 changed files with 10 additions and 5 deletions

View File

@ -10,8 +10,8 @@ type DashBoardStatisticsSt struct {
// 统计过去一周每天的会话数、消息数
type DashBoardStatisticsWeekSt struct {
SessionCount []int64 `json:"session_count"`
MessageCount []int64 `json:"message_count"`
SessionCount map[int]int64 `json:"session_count"`
MessageCount map[int]int64 `json:"message_count"`
}
type DashBoardStatisticsResp struct {

View File

@ -132,17 +132,22 @@ func GetBaseDashboardInfo() proto.DashBoardStatisticsSt {
// 获取最近7天的消息、会话数量
func GetRecent7DaysMessageSessionCount() (proto.DashBoardStatisticsWeekSt, error) {
var res proto.DashBoardStatisticsWeekSt
var err error
res.SessionCount, err = dao.FindSessionCountByDate()
SessionCounts, err := dao.FindSessionCountByDate()
if err != nil {
log.Println("get recent 7 days session count error:", err)
return res, err
}
res.MessageCount, err = dao.FindMessageCountByDate()
for i := 0; i < len(SessionCounts); i++ {
res.SessionCount[i] = SessionCounts[i]
}
MessageCounts, err := dao.FindMessageCountByDate()
if err != nil {
log.Println("get recent 7 days message count error:", err)
return res, err
}
for i := 0; i < len(MessageCounts); i++ {
res.MessageCount[i] = MessageCounts[i]
}
return res, nil
}