From b9b23a2c735801d79fe6eca70880ffde98102bd2 Mon Sep 17 00:00:00 2001 From: Umputun Date: Fri, 2 Mar 2018 00:43:08 -0600 Subject: [PATCH] make last sorted by ts --- app/store/bolt.go | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/app/store/bolt.go b/app/store/bolt.go index 227f5582..59a57ecb 100644 --- a/app/store/bolt.go +++ b/app/store/bolt.go @@ -117,7 +117,8 @@ func (b *BoltDB) Create(comment Comment) (commentID string, err error) { // add reference to comment to "last" bucket lastBkt := tx.Bucket([]byte(lastBucketName)) ref := b.makeRef(comment) - e = lastBkt.Put(ref, ref) + commentTs := []byte(comment.Timestamp.Format(time.RFC3339Nano)) + e = lastBkt.Put(commentTs, ref) if e != nil { return errors.Wrapf(e, "can't put reference %s to %s", ref, lastBucketName) } @@ -130,7 +131,7 @@ func (b *BoltDB) Create(comment Comment) (commentID string, err error) { return errors.Wrapf(e, "can't get bucket %s", comment.User.ID) } // put into individual user's bucket with ts as a key - if e = userIDBkt.Put([]byte(comment.Timestamp.Format(time.RFC3339Nano)), ref); e != nil { + if e = userIDBkt.Put(commentTs, ref); e != nil { return errors.Wrapf(e, "failed to put user comment %s for %s", comment.ID, comment.User.ID) }