From af2f86df243709bc46ba079eb78aabc15b20866d Mon Sep 17 00:00:00 2001 From: Steve Manuel Date: Tue, 18 Oct 2016 13:54:00 -0700 Subject: implement Sort on all content types by Timestamp, DESC (latest to oldest) - run in goroutine on db.Init() as well as any time content is saved via SetContent --- system/db/content.go | 4 +--- system/db/init.go | 2 ++ 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/system/db/content.go b/system/db/content.go index 35f690f..542d539 100644 --- a/system/db/content.go +++ b/system/db/content.go @@ -208,8 +208,6 @@ func ContentAll(namespace string) [][]byte { func SortContent(namespace string) { all := ContentAll(namespace) - fmt.Println(all) - var posts sortablePosts // decode each (json) into Editable for i := range all { @@ -245,7 +243,7 @@ func SortContent(namespace string) { return err } - // encode to json and store as i-post.Time():post + // encode to json and store as 'i:post.Time()':post for i := range posts { j, err := json.Marshal(posts[i]) if err != nil { diff --git a/system/db/init.go b/system/db/init.go index 58bb773..d035510 100644 --- a/system/db/init.go +++ b/system/db/init.go @@ -33,6 +33,8 @@ func Init() { if err != nil { return err } + + go SortContent(t + "_sorted") } // init db with other buckets as needed -- cgit v1.2.3