summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSteve Manuel <nilslice@gmail.com>2016-10-18 13:54:00 -0700
committerSteve Manuel <nilslice@gmail.com>2016-10-18 13:54:00 -0700
commitaf2f86df243709bc46ba079eb78aabc15b20866d (patch)
tree3d09d09002fdf634bd7ece3c81e42a31c32a08a5
parent030d3eb0fc6e2cb22d7ba7c1cf1744592deebbf4 (diff)
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
-rw-r--r--system/db/content.go4
-rw-r--r--system/db/init.go2
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