boweniac 3 месяцев назад
Родитель
Сommit
91c52ff336
1 измененных файлов с 5 добавлено и 4 удалено
  1. 5 4
      crontask/compute_statistic.go

+ 5 - 4
crontask/compute_statistic.go

@@ -132,12 +132,13 @@ func (l *CronTask) computeStatistic() {
 			allHourAccountBalanceInt = 0
 
 			// 活跃好友:usage_detail 表 type = 1
-			activeUserInt, _ = l.svcCtx.DB.UsageDetail.Query().Where(
+			activeUsers, _ := l.svcCtx.DB.UsageDetail.Query().Where(
 				usagedetail.Type(1),
 				usagedetail.BotID(wxinfo.Wxid),
 				usagedetail.CreatedAtGTE(lastHour),
 				usagedetail.CreatedAtLT(currentHour),
-			).GroupBy(usagedetail.FieldReceiverID).Int(l.ctx)
+			).GroupBy(usagedetail.FieldReceiverID).Strings(l.ctx)
+			activeUserInt = len(activeUsers)
 			orgActiveUserInt += activeUserInt
 			allHourActiveUserInt += activeUserInt
 
@@ -148,9 +149,9 @@ func (l *CronTask) computeStatistic() {
 			).First(l.ctx)
 
 			if lastHourData == nil {
-				newUserInt = friendCountInt
+				newUserInt = 0
 			} else {
-				newUserInt = int(lastHourData.TotalFriend) - friendCountInt
+				newUserInt = friendCountInt - int(lastHourData.TotalFriend)
 			}
 			orgNewUserInt += newUserInt
 			allHourNewUserInt += newUserInt