Sort ascending

This commit is contained in:
Peter Stuifzand 2018-04-07 16:40:29 +02:00
parent 6477288fee
commit 7baf3a9ce5

View File

@ -252,7 +252,7 @@ func (b *memoryBackend) TimelineGet(after, before, channel string) microsub.Time
channelKey := fmt.Sprintf("channel:%s:posts", channel)
itemJsons, err := redis.ByteSlices(b.Redis.Do("SORT", channelKey, "BY", "*->Published", "GET", "*->Data", "DESC", "ALPHA"))
itemJsons, err := redis.ByteSlices(b.Redis.Do("SORT", channelKey, "BY", "*->Published", "GET", "*->Data", "ASC", "ALPHA"))
if err != nil {
log.Println(err)
return microsub.Timeline{
@ -267,13 +267,6 @@ func (b *memoryBackend) TimelineGet(after, before, channel string) microsub.Time
items = append(items, item)
}
// sort.SliceStable(items, func(a, b int) bool {
// timeA := items[a].Published
// timeB := items[b].Published
// return strings.Compare(timeA, timeB) > 0
// })
// reverseSlice(items)
return microsub.Timeline{
Paging: microsub.Pagination{},
Items: items,