diff options
author | JoramWilander <jwawilander@gmail.com> | 2015-08-11 10:54:26 -0400 |
---|---|---|
committer | JoramWilander <jwawilander@gmail.com> | 2015-08-11 12:11:35 -0400 |
commit | 3f38c217962829e94927c0e1e12b894ffaae72bb (patch) | |
tree | f2a86cf6c0f5ac550d467a6f0ed29f0a140f6658 /model | |
parent | cb17851e2df46f4a76ef4eefda980df818b4b01d (diff) | |
download | chat-3f38c217962829e94927c0e1e12b894ffaae72bb.tar.gz chat-3f38c217962829e94927c0e1e12b894ffaae72bb.tar.bz2 chat-3f38c217962829e94927c0e1e12b894ffaae72bb.zip |
fixed channel counts etag to only update when appropriate
Diffstat (limited to 'model')
-rw-r--r-- | model/channel_count.go | 15 |
1 files changed, 12 insertions, 3 deletions
diff --git a/model/channel_count.go b/model/channel_count.go index f53e6acaf..d5daba14e 100644 --- a/model/channel_count.go +++ b/model/channel_count.go @@ -6,7 +6,9 @@ package model import ( "crypto/md5" "encoding/json" + "fmt" "io" + "sort" "strconv" ) @@ -16,12 +18,19 @@ type ChannelCounts struct { } func (o *ChannelCounts) Etag() string { + + ids := []string{} + for id, _ := range o.Counts { + ids = append(ids, id) + } + sort.Strings(ids) + str := "" - for id, count := range o.Counts { - str += id + strconv.FormatInt(count, 10) + for _, id := range ids { + str += id + strconv.FormatInt(o.Counts[id], 10) } - md5Counts := md5.Sum([]byte(str)) + md5Counts := fmt.Sprintf("%x", md5.Sum([]byte(str))) var update int64 = 0 for _, u := range o.UpdateTimes { |