summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--api/channel_test.go2
-rw-r--r--model/channel_count.go15
2 files changed, 13 insertions, 4 deletions
diff --git a/api/channel_test.go b/api/channel_test.go
index 1332360ad..d65aff66c 100644
--- a/api/channel_test.go
+++ b/api/channel_test.go
@@ -422,7 +422,7 @@ func TestGetChannelCounts(t *testing.T) {
t.Fatal(err)
} else if cache_result.Data.(*model.ChannelCounts) != nil {
t.Log(cache_result.Data)
- t.Fatal("cache should be empty")
+ t.Fatal("result data should be empty")
}
}
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 {