From 64c3c9c78b7524492f21afa9f449125cec8fa924 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=9D=8E=E5=AF=BB=E6=AC=A2?= Date: Sun, 10 Mar 2024 07:36:10 +0800 Subject: [PATCH 1/2] =?UTF-8?q?:art:=20=E9=80=BB=E8=BE=91=E4=BC=98?= =?UTF-8?q?=E5=8C=96?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- tasks/watergroup/month.go | 5 ++++- tasks/watergroup/week.go | 5 ++++- tasks/watergroup/year.go | 5 ++++- tasks/watergroup/yesterday.go | 5 ++++- 4 files changed, 16 insertions(+), 4 deletions(-) diff --git a/tasks/watergroup/month.go b/tasks/watergroup/month.go index fd7703b..bcd99d1 100644 --- a/tasks/watergroup/month.go +++ b/tasks/watergroup/month.go @@ -60,7 +60,10 @@ 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) } diff --git a/tasks/watergroup/week.go b/tasks/watergroup/week.go index a27298a..6598ca2 100644 --- a/tasks/watergroup/week.go +++ b/tasks/watergroup/week.go @@ -59,7 +59,10 @@ 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) } diff --git a/tasks/watergroup/year.go b/tasks/watergroup/year.go index 255fa8c..3d07bcf 100644 --- a/tasks/watergroup/year.go +++ b/tasks/watergroup/year.go @@ -59,7 +59,10 @@ 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) } diff --git a/tasks/watergroup/yesterday.go b/tasks/watergroup/yesterday.go index 77adc5a..697f721 100644 --- a/tasks/watergroup/yesterday.go +++ b/tasks/watergroup/yesterday.go @@ -61,7 +61,10 @@ 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) } -- 2.45.2 From a548af9de2be7f030c693710648625150105b07b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=9D=8E=E5=AF=BB=E6=AC=A2?= Date: Mon, 11 Mar 2024 14:55:10 +0800 Subject: [PATCH 2/2] =?UTF-8?q?:bug:=20=E4=BF=AE=E5=A4=8D=E6=B4=BB?= =?UTF-8?q?=E8=B7=83=E5=BA=A6=E4=B8=8D=E5=8F=91=E9=80=81=E7=9A=84BUG?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- tasks/watergroup/month.go | 2 +- tasks/watergroup/week.go | 2 +- tasks/watergroup/year.go | 2 +- tasks/watergroup/yesterday.go | 2 +- 4 files changed, 4 insertions(+), 4 deletions(-) diff --git a/tasks/watergroup/month.go b/tasks/watergroup/month.go index bcd99d1..e0c8e75 100644 --- a/tasks/watergroup/month.go +++ b/tasks/watergroup/month.go @@ -68,7 +68,7 @@ func dealMonth(gid string) { 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 6598ca2..43c315a 100644 --- a/tasks/watergroup/week.go +++ b/tasks/watergroup/week.go @@ -67,7 +67,7 @@ func dealWeek(gid string) { 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 3d07bcf..20b8a36 100644 --- a/tasks/watergroup/year.go +++ b/tasks/watergroup/year.go @@ -67,7 +67,7 @@ func dealYear(gid string) { 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 697f721..ab01626 100644 --- a/tasks/watergroup/yesterday.go +++ b/tasks/watergroup/yesterday.go @@ -69,7 +69,7 @@ func dealYesterday(gid string) { 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) -- 2.45.2