summaryrefslogtreecommitdiffstats
path: root/store/sql_channel_store.go
diff options
context:
space:
mode:
author=Corey Hulen <corey@hulen.com>2015-07-12 19:12:23 -0800
committer=Corey Hulen <corey@hulen.com>2015-07-12 19:28:58 -0800
commitaf63080c0dba1bf2c93e4a7996fd7ec07546f289 (patch)
treeed6bb32e5e5e194a7e3202847efdbd14d38abc7e /store/sql_channel_store.go
parent34d56294a240a38722d2d752c63ce087de625080 (diff)
downloadchat-af63080c0dba1bf2c93e4a7996fd7ec07546f289.tar.gz
chat-af63080c0dba1bf2c93e4a7996fd7ec07546f289.tar.bz2
chat-af63080c0dba1bf2c93e4a7996fd7ec07546f289.zip
minor tweaks to make sure mysql still runs
Diffstat (limited to 'store/sql_channel_store.go')
-rw-r--r--store/sql_channel_store.go24
1 files changed, 20 insertions, 4 deletions
diff --git a/store/sql_channel_store.go b/store/sql_channel_store.go
index d192006f5..5aa7f21f9 100644
--- a/store/sql_channel_store.go
+++ b/store/sql_channel_store.go
@@ -494,8 +494,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,
@@ -507,8 +509,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())
}