summaryrefslogtreecommitdiffstats
path: root/model/channel_count.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 /model/channel_count.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 'model/channel_count.go')
-rw-r--r--model/channel_count.go14
1 files changed, 11 insertions, 3 deletions
diff --git a/model/channel_count.go b/model/channel_count.go
index 05d8401e1..f53e6acaf 100644
--- a/model/channel_count.go
+++ b/model/channel_count.go
@@ -11,7 +11,8 @@ import (
)
type ChannelCounts struct {
- Counts map[string]int64 `json:"counts"`
+ Counts map[string]int64 `json:"counts"`
+ UpdateTimes map[string]int64 `json:"update_times"`
}
func (o *ChannelCounts) Etag() string {
@@ -20,9 +21,16 @@ func (o *ChannelCounts) Etag() string {
str += id + strconv.FormatInt(count, 10)
}
- data := []byte(str)
+ md5Counts := md5.Sum([]byte(str))
- return Etag(md5.Sum(data))
+ var update int64 = 0
+ for _, u := range o.UpdateTimes {
+ if u > update {
+ update = u
+ }
+ }
+
+ return Etag(md5Counts, update)
}
func (o *ChannelCounts) ToJson() string {