diff --git a/tasks/watergroup/month.go b/tasks/watergroup/month.go index fd7703bf..e0c8e75b 100644 --- a/tasks/watergroup/month.go +++ b/tasks/watergroup/month.go @@ -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) diff --git a/tasks/watergroup/week.go b/tasks/watergroup/week.go index a27298a3..43c315ab 100644 --- a/tasks/watergroup/week.go +++ b/tasks/watergroup/week.go @@ -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) diff --git a/tasks/watergroup/year.go b/tasks/watergroup/year.go index 255fa8ce..20b8a362 100644 --- a/tasks/watergroup/year.go +++ b/tasks/watergroup/year.go @@ -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) diff --git a/tasks/watergroup/yesterday.go b/tasks/watergroup/yesterday.go index 77adc5af..ab01626e 100644 --- a/tasks/watergroup/yesterday.go +++ b/tasks/watergroup/yesterday.go @@ -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)