2017-06-26 21:41:16 +00:00
|
|
|
package main
|
|
|
|
|
|
|
|
import (
|
|
|
|
"github.com/animenotifier/arn"
|
|
|
|
)
|
|
|
|
|
|
|
|
func main() {
|
2017-11-01 19:11:05 +00:00
|
|
|
defer arn.Node.Close()
|
2017-06-26 21:41:16 +00:00
|
|
|
|
2017-11-01 19:11:05 +00:00
|
|
|
// Get a stream of all posts
|
2017-06-26 21:41:16 +00:00
|
|
|
threadToPosts := make(map[string][]string)
|
|
|
|
|
|
|
|
// Iterate over the stream
|
2017-11-01 19:11:05 +00:00
|
|
|
for post := range arn.StreamPosts() {
|
2018-10-29 00:28:24 +00:00
|
|
|
if post.ParentType != "Thread" {
|
|
|
|
continue
|
|
|
|
}
|
|
|
|
|
|
|
|
_, found := threadToPosts[post.ParentID]
|
2017-06-26 21:41:16 +00:00
|
|
|
|
|
|
|
if !found {
|
2018-10-29 00:28:24 +00:00
|
|
|
threadToPosts[post.ParentID] = []string{post.ID}
|
2017-06-26 21:41:16 +00:00
|
|
|
} else {
|
2018-10-29 00:28:24 +00:00
|
|
|
threadToPosts[post.ParentID] = append(threadToPosts[post.ParentID], post.ID)
|
2017-06-26 21:41:16 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
// Save new post ID lists
|
|
|
|
for threadID, posts := range threadToPosts {
|
|
|
|
thread, err := arn.GetThread(threadID)
|
|
|
|
arn.PanicOnError(err)
|
|
|
|
|
2018-10-29 00:28:24 +00:00
|
|
|
thread.PostIDs = posts
|
2017-11-01 19:11:05 +00:00
|
|
|
thread.Save()
|
2017-06-26 21:41:16 +00:00
|
|
|
}
|
|
|
|
}
|