diff options
author | =Corey Hulen <corey@hulen.com> | 2015-07-12 19:12:23 -0800 |
---|---|---|
committer | =Corey Hulen <corey@hulen.com> | 2015-07-12 19:12:23 -0800 |
commit | 443a386f775dba732fa788625dc99438d16d3931 (patch) | |
tree | 7b879e2e31fc46d9feb2262a775fd09003b4bffc /store/sql_channel_store.go | |
parent | cf11d387eef7883d8c2866d8bb44887120499963 (diff) | |
download | chat-443a386f775dba732fa788625dc99438d16d3931.tar.gz chat-443a386f775dba732fa788625dc99438d16d3931.tar.bz2 chat-443a386f775dba732fa788625dc99438d16d3931.zip |
minor tweaks to make sure mysql still runs
Diffstat (limited to 'store/sql_channel_store.go')
-rw-r--r-- | store/sql_channel_store.go | 24 |
1 files changed, 20 insertions, 4 deletions
diff --git a/store/sql_channel_store.go b/store/sql_channel_store.go index 9dabf6c30..717f54d05 100644 --- a/store/sql_channel_store.go +++ b/store/sql_channel_store.go @@ -482,8 +482,10 @@ func (s SqlChannelStore) UpdateLastViewedAt(channelId string, userId string) Sto go func() { result := StoreResult{} - _, err := s.GetMaster().Exec( - `UPDATE + var query string + + if utils.Cfg.SqlSettings.DriverName == "postgres" { + query = `UPDATE ChannelMembers SET MentionCount = 0, @@ -495,8 +497,22 @@ func (s SqlChannelStore) UpdateLastViewedAt(channelId string, userId string) Sto WHERE Channels.Id = ChannelMembers.ChannelId AND UserId = :UserId - AND ChannelId = :ChannelId`, - map[string]interface{}{"ChannelId": channelId, "UserId": userId}) + AND ChannelId = :ChannelId` + } else if utils.Cfg.SqlSettings.DriverName == "mysql" { + query = `UPDATE + ChannelMembers, Channels + SET + ChannelMembers.MentionCount = 0, + ChannelMembers.MsgCount = Channels.TotalMsgCount, + ChannelMembers.LastViewedAt = Channels.LastPostAt, + ChannelMembers.LastUpdateAt = Channels.LastPostAt + WHERE + Channels.Id = ChannelMembers.ChannelId + AND UserId = :UserId + AND ChannelId = :ChannelId` + } + + _, err := s.GetMaster().Exec(query, map[string]interface{}{"ChannelId": channelId, "UserId": userId}) if err != nil { result.Err = model.NewAppError("SqlChannelStore.UpdateLastViewedAt", "We couldn't update the last viewed at time", "channel_id="+channelId+", user_id="+userId+", "+err.Error()) } |