33 lines
631 B
Go
Raw Normal View History

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() {
2017-06-26 21:41:16 +00:00
_, found := threadToPosts[post.ThreadID]
if !found {
threadToPosts[post.ThreadID] = []string{post.ID}
} else {
threadToPosts[post.ThreadID] = append(threadToPosts[post.ThreadID], post.ID)
}
}
// Save new post ID lists
for threadID, posts := range threadToPosts {
thread, err := arn.GetThread(threadID)
arn.PanicOnError(err)
thread.Posts = posts
2017-11-01 19:11:05 +00:00
thread.Save()
2017-06-26 21:41:16 +00:00
}
}