summaryrefslogtreecommitdiffstats
path: root/store/sql_user_store.go
diff options
context:
space:
mode:
authorJoram Wilander <jwawilander@gmail.com>2017-03-07 16:05:01 -0500
committerGitHub <noreply@github.com>2017-03-07 16:05:01 -0500
commit83291e4c8fd1c2d234ac9f4254af849bed64cabf (patch)
tree7457bacc4b91c35fa100d6b77fed1f411b36dcf5 /store/sql_user_store.go
parente753d3dc3c8aeb6d4a8acc48ec1fa9ead10eb6ab (diff)
downloadchat-83291e4c8fd1c2d234ac9f4254af849bed64cabf.tar.gz
chat-83291e4c8fd1c2d234ac9f4254af849bed64cabf.tar.bz2
chat-83291e4c8fd1c2d234ac9f4254af849bed64cabf.zip
Merge 3.7 changes into master (#5679)
* Save schema version for 3.7 (#5675) * Adding index and cache to reactinos store (#5654) * Fix badge count for push notifications (#5672)
Diffstat (limited to 'store/sql_user_store.go')
-rw-r--r--store/sql_user_store.go8
1 files changed, 7 insertions, 1 deletions
diff --git a/store/sql_user_store.go b/store/sql_user_store.go
index 838c2a80d..23b0c3696 100644
--- a/store/sql_user_store.go
+++ b/store/sql_user_store.go
@@ -1179,7 +1179,13 @@ func (us SqlUserStore) GetUnreadCount(userId string) StoreChannel {
go func() {
result := StoreResult{}
- if count, err := us.GetReplica().SelectInt("SELECT SUM(CASE WHEN c.Type = 'D' THEN (c.TotalMsgCount - cm.MsgCount) ELSE cm.MentionCount END) FROM Channels c INNER JOIN ChannelMembers cm ON cm.ChannelId = c.Id AND cm.UserId = :UserId", map[string]interface{}{"UserId": userId}); err != nil {
+ if count, err := us.GetReplica().SelectInt(`
+ SELECT SUM(CASE WHEN c.Type = 'D' THEN (c.TotalMsgCount - cm.MsgCount) ELSE cm.MentionCount END)
+ FROM Channels c
+ INNER JOIN ChannelMembers cm
+ ON cm.ChannelId = c.Id
+ AND cm.UserId = :UserId
+ AND c.DeleteAt = 0`, map[string]interface{}{"UserId": userId}); err != nil {
result.Err = model.NewLocAppError("SqlUserStore.GetMentionCount", "store.sql_user.get_unread_count.app_error", nil, err.Error())
} else {
result.Data = count