Added patch to sort threads
This commit is contained in:
parent
9e36f03d15
commit
87c2ce509e
26
patches/post-sort-date/post-sort-date.go
Normal file
26
patches/post-sort-date/post-sort-date.go
Normal file
@ -0,0 +1,26 @@
|
|||||||
|
package main
|
||||||
|
|
||||||
|
import (
|
||||||
|
"github.com/animenotifier/arn"
|
||||||
|
"github.com/fatih/color"
|
||||||
|
)
|
||||||
|
|
||||||
|
func main() {
|
||||||
|
color.Yellow("Sorting posts by date")
|
||||||
|
|
||||||
|
defer color.Green("Finished.")
|
||||||
|
defer arn.Node.Close()
|
||||||
|
|
||||||
|
for thread := range arn.StreamThreads() {
|
||||||
|
posts := thread.Posts()
|
||||||
|
arn.SortPostsLatestLast(posts)
|
||||||
|
postIDs := []string{}
|
||||||
|
|
||||||
|
for _, post := range posts {
|
||||||
|
postIDs = append(postIDs, post.ID)
|
||||||
|
}
|
||||||
|
|
||||||
|
thread.PostIDs = postIDs
|
||||||
|
thread.Save()
|
||||||
|
}
|
||||||
|
}
|
Loading…
Reference in New Issue
Block a user