perf(dashboard): delete unused code
This commit is contained in:
@@ -562,18 +562,10 @@ func (s *Service) handleDashboard(c *gin.Context) {
|
||||
Links int64 `json:"links"`
|
||||
Others int64 `json:"others"`
|
||||
}
|
||||
type HourlyActivity struct {
|
||||
Group string `json:"group"`
|
||||
Name string `json:"name"`
|
||||
Total int64 `json:"total_messages"`
|
||||
Series []HourlySeries `json:"series"`
|
||||
}
|
||||
type GroupAnalysis struct {
|
||||
Title string `json:"title"`
|
||||
Overview GroupOverview `json:"overview"`
|
||||
ContentAnalysis ContentAnalysis `json:"content_analysis"`
|
||||
GroupList []OverviewGroup `json:"group_list"`
|
||||
HourlyActivity []HourlyActivity `json:"hourly_activity"`
|
||||
Title string `json:"title"`
|
||||
Overview GroupOverview `json:"overview"`
|
||||
ContentAnalysis ContentAnalysis `json:"content_analysis"`
|
||||
}
|
||||
type ContentTypeStats struct {
|
||||
Count int64 `json:"count"`
|
||||
@@ -638,47 +630,6 @@ func (s *Service) handleDashboard(c *gin.Context) {
|
||||
Sunday: heat[h][0],
|
||||
})
|
||||
}
|
||||
// hourly activity typed(每个群独立统计)
|
||||
type groupHourlyAgg struct {
|
||||
id string
|
||||
name string
|
||||
total int64
|
||||
hours [24]int64
|
||||
}
|
||||
ghagg := make([]groupHourlyAgg, 0, len(groupHourlyRaw))
|
||||
for gid, arr := range groupHourlyRaw {
|
||||
var total int64
|
||||
for _, v := range arr {
|
||||
total += v
|
||||
}
|
||||
// 如果全天无消息则跳过
|
||||
if total == 0 {
|
||||
continue
|
||||
}
|
||||
name := groupNameMap[gid]
|
||||
if strings.TrimSpace(name) == "" {
|
||||
name = gid
|
||||
}
|
||||
ghagg = append(ghagg, groupHourlyAgg{id: gid, name: name, total: total, hours: arr})
|
||||
}
|
||||
sort.Slice(ghagg, func(i, j int) bool {
|
||||
if ghagg[i].total == ghagg[j].total {
|
||||
return ghagg[i].name < ghagg[j].name
|
||||
}
|
||||
return ghagg[i].total > ghagg[j].total
|
||||
})
|
||||
hacts := make([]HourlyActivity, 0, len(ghagg))
|
||||
for _, item := range ghagg {
|
||||
series := make([]HourlySeries, 0, 24)
|
||||
for h := 0; h < 24; h++ {
|
||||
if item.hours[h] == 0 {
|
||||
continue
|
||||
}
|
||||
series = append(series, HourlySeries{Hour: fmt.Sprintf("%02d:00", h), Messages: item.hours[h]})
|
||||
}
|
||||
hacts = append(hacts, HourlyActivity{Group: item.id, Name: item.name, Total: item.total, Series: series})
|
||||
}
|
||||
|
||||
// ====== 今日群聊消息数统计 ======
|
||||
todayMessages := int64(0)
|
||||
if s.db != nil && s.db.GetDB() != nil {
|
||||
@@ -882,8 +833,6 @@ func (s *Service) handleDashboard(c *gin.Context) {
|
||||
Overview: GroupOverview{TotalGroups: len(overviewGroups), ActiveGroups: activeGroups, TodayMessages: int(todayMessages), WeeklyAvg: weeklyAvg, MostActiveHour: mostActiveHour},
|
||||
// 扩展:增加 links 字段(结构体需更新)
|
||||
ContentAnalysis: ContentAnalysis{Text: msgTypes["文本消息"], Images: msgTypes["图片消息"], Voice: msgTypes["语音消息"], Files: msgTypes["文件消息"], Links: msgTypes["链接消息"], Others: totalMsgs - (msgTypes["文本消息"] + msgTypes["图片消息"] + msgTypes["语音消息"] + msgTypes["文件消息"] + msgTypes["链接消息"])},
|
||||
GroupList: ogroups,
|
||||
HourlyActivity: hacts,
|
||||
},
|
||||
DataTypeAnalysis: DataTypeAnalysis{
|
||||
Title: "数据类型统计",
|
||||
|
||||
Reference in New Issue
Block a user