From 5469bb6508179a97e686e1b3b103206ca6c79d18 Mon Sep 17 00:00:00 2001 From: wangchuxiao Date: Tue, 6 Sep 2022 17:46:55 +0800 Subject: [PATCH] fix bug --- .../db/mysql_model/im_mysql_model/message_cms.go | 10 +++++----- .../db/mysql_model/im_mysql_model/statistics_model.go | 1 + 2 files changed, 6 insertions(+), 5 deletions(-) diff --git a/pkg/common/db/mysql_model/im_mysql_model/message_cms.go b/pkg/common/db/mysql_model/im_mysql_model/message_cms.go index a32f1730b..eb37aae80 100644 --- a/pkg/common/db/mysql_model/im_mysql_model/message_cms.go +++ b/pkg/common/db/mysql_model/im_mysql_model/message_cms.go @@ -47,14 +47,14 @@ func GetChatLogCount(chatLog db.ChatLog) (int64, error) { if chatLog.Content != "" { db = db.Where(" content like ? ", fmt.Sprintf("%%%s%%", chatLog.Content)) } - if chatLog.SessionType != 0 { + if chatLog.SessionType == 1 { db = db.Where("session_type = ?", chatLog.SessionType) - } - if chatLog.ContentType == 1 { - db = db.Where("content_type = ?", chatLog.ContentType) - } else if chatLog.ContentType == 2 { + } else if chatLog.SessionType == 2 { db = db.Where("content_type in (?)", []int{constant.GroupChatType, constant.SuperGroupChatType}) } + if chatLog.ContentType != 0 { + db = db.Where("content_type = ?", chatLog.ContentType) + } if chatLog.SendID != "" { db = db.Where("send_id = ?", chatLog.SendID) } diff --git a/pkg/common/db/mysql_model/im_mysql_model/statistics_model.go b/pkg/common/db/mysql_model/im_mysql_model/statistics_model.go index 4a8626cf0..bdd06f662 100644 --- a/pkg/common/db/mysql_model/im_mysql_model/statistics_model.go +++ b/pkg/common/db/mysql_model/im_mysql_model/statistics_model.go @@ -97,6 +97,7 @@ func GetActiveUsers(from, to time.Time, limit int) ([]*activeUser, error) { continue } activeUser.Name = user.Nickname + activeUser.ID = user.UserID } return activeUsers, err }