summaryrefslogtreecommitdiffstats
path: root/store/sql_channel_store.go
diff options
context:
space:
mode:
authorJoramWilander <jwawilander@gmail.com>2015-08-11 08:20:17 -0400
committerJoramWilander <jwawilander@gmail.com>2015-08-11 12:11:35 -0400
commit4ec76e059cddc127c35bf758f7fda7c7636c8d70 (patch)
tree4ecc9322edf6eba7cf8f47d655339861b3e54ae9 /store/sql_channel_store.go
parent6c0fefad152e1843bccf80fb675301b789f70dd5 (diff)
downloadchat-4ec76e059cddc127c35bf758f7fda7c7636c8d70.tar.gz
chat-4ec76e059cddc127c35bf758f7fda7c7636c8d70.tar.bz2
chat-4ec76e059cddc127c35bf758f7fda7c7636c8d70.zip
incorporate channel updateAt into channel counts and pull channel data on channel update
Diffstat (limited to 'store/sql_channel_store.go')
-rw-r--r--store/sql_channel_store.go10
1 files changed, 6 insertions, 4 deletions
diff --git a/store/sql_channel_store.go b/store/sql_channel_store.go
index 6caa6fc70..7b2d9df24 100644
--- a/store/sql_channel_store.go
+++ b/store/sql_channel_store.go
@@ -281,9 +281,10 @@ func (s SqlChannelStore) GetMoreChannels(teamId string, userId string) StoreChan
return storeChannel
}
-type channelIdWithCount struct {
+type channelIdWithCountandUpdateAt struct {
Id string
TotalMsgCount int64
+ UpdateAt int64
}
func (s SqlChannelStore) GetChannelCounts(teamId string, userId string) StoreChannel {
@@ -292,16 +293,17 @@ func (s SqlChannelStore) GetChannelCounts(teamId string, userId string) StoreCha
go func() {
result := StoreResult{}
- var data []channelIdWithCount
- _, err := s.GetReplica().Select(&data, "SELECT Id, TotalMsgCount FROM Channels WHERE Id IN (SELECT ChannelId FROM ChannelMembers WHERE UserId = :UserId) AND TeamId = :TeamId AND DeleteAt = 0 ORDER BY DisplayName", map[string]interface{}{"TeamId": teamId, "UserId": userId})
+ var data []channelIdWithCountandUpdateAt
+ _, err := s.GetReplica().Select(&data, "SELECT Id, TotalMsgCount, UpdateAt FROM Channels WHERE Id IN (SELECT ChannelId FROM ChannelMembers WHERE UserId = :UserId) AND TeamId = :TeamId AND DeleteAt = 0 ORDER BY DisplayName", map[string]interface{}{"TeamId": teamId, "UserId": userId})
if err != nil {
result.Err = model.NewAppError("SqlChannelStore.GetChannelCounts", "We couldn't get the channel counts", "teamId="+teamId+", userId="+userId+", err="+err.Error())
} else {
- counts := &model.ChannelCounts{Counts: make(map[string]int64)}
+ counts := &model.ChannelCounts{Counts: make(map[string]int64), UpdateTimes: make(map[string]int64)}
for i := range data {
v := data[i]
counts.Counts[v.Id] = v.TotalMsgCount
+ counts.UpdateTimes[v.Id] = v.UpdateAt
}
result.Data = counts