diff --git a/tasks/watergroup/month.go b/tasks/watergroup/month.go index 971df23e..f3b8c81f 100644 --- a/tasks/watergroup/month.go +++ b/tasks/watergroup/month.go @@ -74,14 +74,16 @@ func dealMonth(gid string) { activity = fmt.Sprintf("%.2f", (float64(len(records))/float64(groupUsers))*100) } - // 计算消息总数、中位数 - var msgCount int64 - var medianCount int64 + // 计算消息总数、中位数、前十位消息总数 + var msgCount, medianCount, topTenCount int64 for idx, v := range records { msgCount += v.Count if idx == (len(records)/2)-1 { medianCount = v.Count } + if len(records) > 10 && idx < 10 { + topTenCount += v.Count + } } // 计算活跃用户人均消息条数 avgMsgCount := int(float64(msgCount) / float64(len(records))) @@ -90,7 +92,12 @@ func dealMonth(gid string) { notifyMsgs = append(notifyMsgs, " ") notifyMsgs = append(notifyMsgs, fmt.Sprintf("🗣️ %s本群 %d 位朋友共产生 %d 条发言", monthStr, len(records), msgCount)) if showActivity { - notifyMsgs = append(notifyMsgs, fmt.Sprintf("🎭 活跃度: %s%%,人均消息条数: %d,中位数: %d", activity, avgMsgCount, medianCount)) + m := fmt.Sprintf("🎭 活跃度: %s%%,人均消息条数: %d,中位数: %d", activity, avgMsgCount, medianCount) + // 计算前十占比 + if topTenCount > 0 { + m += fmt.Sprintf(",前十名占比: %.2f%%", float64(topTenCount)/float64(msgCount)*100) + } + notifyMsgs = append(notifyMsgs, m) } notifyMsgs = append(notifyMsgs, "\n🏵 活跃用户排行榜 🏵") diff --git a/tasks/watergroup/week.go b/tasks/watergroup/week.go index b8df0c95..b4902c07 100644 --- a/tasks/watergroup/week.go +++ b/tasks/watergroup/week.go @@ -73,14 +73,16 @@ func dealWeek(gid string) { activity = fmt.Sprintf("%.2f", (float64(len(records))/float64(groupUsers))*100) } - // 计算消息总数、中位数 - var msgCount int64 - var medianCount int64 + // 计算消息总数、中位数、前十位消息总数 + var msgCount, medianCount, topTenCount int64 for idx, v := range records { msgCount += v.Count if idx == (len(records)/2)-1 { medianCount = v.Count } + if len(records) > 10 && idx < 10 { + topTenCount += v.Count + } } // 计算活跃用户人均消息条数 avgMsgCount := int(float64(msgCount) / float64(len(records))) @@ -89,7 +91,12 @@ func dealWeek(gid string) { notifyMsgs = append(notifyMsgs, " ") notifyMsgs = append(notifyMsgs, fmt.Sprintf("🗣️ 上周本群 %d 位朋友共产生 %d 条发言", len(records), msgCount)) if showActivity { - notifyMsgs = append(notifyMsgs, fmt.Sprintf("🎭 活跃度: %s%%,人均消息条数: %d,中位数: %d", activity, avgMsgCount, medianCount)) + m := fmt.Sprintf("🎭 活跃度: %s%%,人均消息条数: %d,中位数: %d", activity, avgMsgCount, medianCount) + // 计算前十占比 + if topTenCount > 0 { + m += fmt.Sprintf(",前十名占比: %.2f%%", float64(topTenCount)/float64(msgCount)*100) + } + notifyMsgs = append(notifyMsgs, m) } notifyMsgs = append(notifyMsgs, "\n🏵 活跃用户排行榜 🏵") diff --git a/tasks/watergroup/year.go b/tasks/watergroup/year.go index aba255a1..8ea50ba7 100644 --- a/tasks/watergroup/year.go +++ b/tasks/watergroup/year.go @@ -73,14 +73,16 @@ func dealYear(gid string) { activity = fmt.Sprintf("%.2f", (float64(len(records))/float64(groupUsers))*100) } - // 计算消息总数、中位数 - var msgCount int64 - var medianCount int64 + // 计算消息总数、中位数、前十位消息总数 + var msgCount, medianCount, topTenCount int64 for idx, v := range records { msgCount += v.Count if idx == (len(records)/2)-1 { medianCount = v.Count } + if len(records) > 10 && idx < 10 { + topTenCount += v.Count + } } // 计算活跃用户人均消息条数 avgMsgCount := int(float64(msgCount) / float64(len(records))) @@ -97,7 +99,12 @@ func dealYear(gid string) { notifyMsgs = append(notifyMsgs, " ") notifyMsgs = append(notifyMsgs, fmt.Sprintf("🗣️ 去年本群 %d 位朋友共产生 %d 条发言", len(records), msgCount)) if showActivity { - notifyMsgs = append(notifyMsgs, fmt.Sprintf("🎭 活跃度: %s%%,人均消息条数: %d,中位数: %d", activity, avgMsgCount, medianCount)) + m := fmt.Sprintf("🎭 活跃度: %s%%,人均消息条数: %d,中位数: %d", activity, avgMsgCount, medianCount) + // 计算前十占比 + if topTenCount > 0 { + m += fmt.Sprintf(",前十名占比: %.2f%%", float64(topTenCount)/float64(msgCount)*100) + } + notifyMsgs = append(notifyMsgs, m) } notifyMsgs = append(notifyMsgs, "\n🏵 活跃用户排行榜 🏵") diff --git a/tasks/watergroup/yesterday.go b/tasks/watergroup/yesterday.go index b932756a..e6b38638 100644 --- a/tasks/watergroup/yesterday.go +++ b/tasks/watergroup/yesterday.go @@ -75,14 +75,16 @@ func dealYesterday(gid string) { activity = fmt.Sprintf("%.2f", (float64(len(records))/float64(groupUsers))*100) } - // 计算消息总数、中位数 - var msgCount int64 - var medianCount int64 + // 计算消息总数、中位数、前十位消息总数 + var msgCount, medianCount, topTenCount int64 for idx, v := range records { msgCount += v.Count if idx == (len(records)/2)-1 { medianCount = v.Count } + if len(records) > 10 && idx < 10 { + topTenCount += v.Count + } } // 计算活跃用户人均消息条数 avgMsgCount := int(float64(msgCount) / float64(len(records))) @@ -91,7 +93,12 @@ func dealYesterday(gid string) { notifyMsgs = append(notifyMsgs, " ") notifyMsgs = append(notifyMsgs, fmt.Sprintf("🗣️ 昨日本群 %d 位朋友共产生 %d 条发言", len(records), msgCount)) if showActivity { - notifyMsgs = append(notifyMsgs, fmt.Sprintf("🎭 活跃度: %s%%,人均消息条数: %d,中位数: %d", activity, avgMsgCount, medianCount)) + m := fmt.Sprintf("🎭 活跃度: %s%%,人均消息条数: %d,中位数: %d", activity, avgMsgCount, medianCount) + // 计算前十占比 + if topTenCount > 0 { + m += fmt.Sprintf(",前十名占比: %.2f%%", float64(topTenCount)/float64(msgCount)*100) + } + notifyMsgs = append(notifyMsgs, m) } notifyMsgs = append(notifyMsgs, "\n🏵 活跃用户排行榜 🏵")