Compare commits

...

3 Commits

Author SHA1 Message Date
8bac050a02 Merge pull request 'hotfix' (#28) from hotfix into main
All checks were successful
BuildImage / build-image (push) Successful in 1m24s
Reviewed-on: #28
2024-03-11 14:56:45 +08:00
a548af9de2 🐛 修复活跃度不发送的BUG 2024-03-11 14:55:10 +08:00
64c3c9c78b 🎨 逻辑优化 2024-03-10 07:36:10 +08:00
4 changed files with 20 additions and 8 deletions

View File

@ -60,12 +60,15 @@ func dealMonth(gid string) {
// 查询群成员总数
var groupUsers int64
err = client.MySQL.Model(&entity.GroupUser{}).Where("group_id = ?", gid).Count(&groupUsers).Error
err = client.MySQL.Model(&entity.GroupUser{}).
Where("group_id = ?", gid).
Where("is_member IS TRUE").
Count(&groupUsers).Error
if err != nil {
log.Printf("查询群成员总数失败, 错误信息: %v", err)
}
// 计算活跃度
showActivity := err != nil && groupUsers > 0
showActivity := err == nil && groupUsers > 0
activity := "0.00"
if groupUsers > 0 {
activity = fmt.Sprintf("%.2f", (float64(len(records))/float64(groupUsers))*100)

View File

@ -59,12 +59,15 @@ func dealWeek(gid string) {
// 查询群成员总数
var groupUsers int64
err = client.MySQL.Model(&entity.GroupUser{}).Where("group_id = ?", gid).Count(&groupUsers).Error
err = client.MySQL.Model(&entity.GroupUser{}).
Where("group_id = ?", gid).
Where("is_member IS TRUE").
Count(&groupUsers).Error
if err != nil {
log.Printf("查询群成员总数失败, 错误信息: %v", err)
}
// 计算活跃度
showActivity := err != nil && groupUsers > 0
showActivity := err == nil && groupUsers > 0
activity := "0.00"
if groupUsers > 0 {
activity = fmt.Sprintf("%.2f", (float64(len(records))/float64(groupUsers))*100)

View File

@ -59,12 +59,15 @@ func dealYear(gid string) {
// 查询群成员总数
var groupUsers int64
err = client.MySQL.Model(&entity.GroupUser{}).Where("group_id = ?", gid).Count(&groupUsers).Error
err = client.MySQL.Model(&entity.GroupUser{}).
Where("group_id = ?", gid).
Where("is_member IS TRUE").
Count(&groupUsers).Error
if err != nil {
log.Printf("查询群成员总数失败, 错误信息: %v", err)
}
// 计算活跃度
showActivity := err != nil && groupUsers > 0
showActivity := err == nil && groupUsers > 0
activity := "0.00"
if groupUsers > 0 {
activity = fmt.Sprintf("%.2f", (float64(len(records))/float64(groupUsers))*100)

View File

@ -61,12 +61,15 @@ func dealYesterday(gid string) {
// 查询群成员总数
var groupUsers int64
err = client.MySQL.Model(&entity.GroupUser{}).Where("group_id = ?", gid).Count(&groupUsers).Error
err = client.MySQL.Model(&entity.GroupUser{}).
Where("group_id = ?", gid).
Where("is_member IS TRUE").
Count(&groupUsers).Error
if err != nil {
log.Printf("查询群成员总数失败, 错误信息: %v", err)
}
// 计算活跃度
showActivity := err != nil && groupUsers > 0
showActivity := err == nil && groupUsers > 0
activity := "0.00"
if groupUsers > 0 {
activity = fmt.Sprintf("%.2f", (float64(len(records))/float64(groupUsers))*100)