Sort comments on Rophako ingest
This commit is contained in:
parent
baaf7bcfac
commit
c664c07a74
|
@ -10,6 +10,7 @@ import (
|
|||
"os"
|
||||
"path/filepath"
|
||||
"regexp"
|
||||
"sort"
|
||||
"strconv"
|
||||
"strings"
|
||||
"time"
|
||||
|
@ -189,6 +190,9 @@ func migrateComments() {
|
|||
t.Post(new)
|
||||
}
|
||||
|
||||
// Re-sort the comments by date.
|
||||
sort.Sort(comments.ByCreated(t.Comments))
|
||||
|
||||
// Check for subscribers
|
||||
subs := legacySubscribers{}
|
||||
err = inDB.Get(fmt.Sprintf("comments/subscribers/%s", id), &subs)
|
||||
|
|
|
@ -60,6 +60,12 @@ type Comment struct {
|
|||
Editing bool `json:"-"`
|
||||
}
|
||||
|
||||
type ByCreated []*Comment
|
||||
|
||||
func (a ByCreated) Len() int { return len(a) }
|
||||
func (a ByCreated) Swap(i, j int) { a[i], a[j] = a[j], a[i] }
|
||||
func (a ByCreated) Less(i, j int) bool { return a[i].Created.Before(a[j].Created) }
|
||||
|
||||
// New initializes a new comment thread.
|
||||
func New(id string) Thread {
|
||||
return Thread{
|
||||
|
|
Loading…
Reference in New Issue
Block a user