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