diff options
author | George Goldberg <george@gberg.me> | 2017-10-24 19:27:15 +0100 |
---|---|---|
committer | Harrison Healey <harrisonmhealey@gmail.com> | 2017-10-24 14:27:15 -0400 |
commit | 61b023f5dfe796c7ba8183292853f01817016d14 (patch) | |
tree | aa0f659b7c913a53737e3954c8568f682601d7fc /model/post_list.go | |
parent | 2a2af0e390e0323e02919598881783f38131b5ee (diff) | |
download | chat-61b023f5dfe796c7ba8183292853f01817016d14.tar.gz chat-61b023f5dfe796c7ba8183292853f01817016d14.tar.bz2 chat-61b023f5dfe796c7ba8183292853f01817016d14.zip |
PLT-7822: Fix search order for SQL search backend. (#7704)
Diffstat (limited to 'model/post_list.go')
-rw-r--r-- | model/post_list.go | 7 |
1 files changed, 7 insertions, 0 deletions
diff --git a/model/post_list.go b/model/post_list.go index b3caadafd..018f7d14f 100644 --- a/model/post_list.go +++ b/model/post_list.go @@ -6,6 +6,7 @@ package model import ( "encoding/json" "io" + "sort" ) type PostList struct { @@ -82,6 +83,12 @@ func (o *PostList) Extend(other *PostList) { } } +func (o *PostList) SortByCreateAt() { + sort.Slice(o.Order, func(i, j int) bool { + return o.Posts[o.Order[i]].CreateAt > o.Posts[o.Order[j]].CreateAt + }) +} + func (o *PostList) Etag() string { id := "0" |