✨ 群消息统计新增活跃用户人均消息条数和中位数
This commit is contained in:
@@ -75,16 +75,23 @@ func dealYesterday(gid string) {
|
||||
activity = fmt.Sprintf("%.2f", (float64(len(records))/float64(groupUsers))*100)
|
||||
}
|
||||
|
||||
// 计算消息总数
|
||||
// 计算消息总数、中位数
|
||||
var msgCount int64
|
||||
for _, v := range records {
|
||||
var medianCount int64
|
||||
for idx, v := range records {
|
||||
msgCount += v.Count
|
||||
if idx == len(records)/2 {
|
||||
medianCount = v.Count
|
||||
}
|
||||
}
|
||||
// 计算活跃用户人均消息条数
|
||||
avgMsgCount := int(float64(msgCount) / float64(len(records)))
|
||||
|
||||
// 组装消息总数推送信息
|
||||
notifyMsgs = append(notifyMsgs, " ")
|
||||
notifyMsgs = append(notifyMsgs, fmt.Sprintf("🗣️ 昨日本群 %d 位朋友共产生 %d 条发言", len(records), msgCount))
|
||||
if showActivity {
|
||||
notifyMsgs = append(notifyMsgs, fmt.Sprintf("🎭 活跃度: %s%%", activity))
|
||||
notifyMsgs = append(notifyMsgs, fmt.Sprintf("🎭 活跃度: %s%%,人均消息条数: %d,中位数: %d", activity, avgMsgCount, medianCount))
|
||||
}
|
||||
notifyMsgs = append(notifyMsgs, "\n🏵 活跃用户排行榜 🏵")
|
||||
|
||||
|
||||
Reference in New Issue
Block a user