From f4f1531b8b08c8094458a031bd4133939263c59d Mon Sep 17 00:00:00 2001 From: Eduard Urbach Date: Mon, 29 Oct 2018 09:28:24 +0900 Subject: [PATCH] Minor fix --- patches/thread-posts/thread-posts.go | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/patches/thread-posts/thread-posts.go b/patches/thread-posts/thread-posts.go index 166d414b..e73fe2b6 100644 --- a/patches/thread-posts/thread-posts.go +++ b/patches/thread-posts/thread-posts.go @@ -12,12 +12,16 @@ func main() { // Iterate over the stream for post := range arn.StreamPosts() { - _, found := threadToPosts[post.ThreadID] + if post.ParentType != "Thread" { + continue + } + + _, found := threadToPosts[post.ParentID] if !found { - threadToPosts[post.ThreadID] = []string{post.ID} + threadToPosts[post.ParentID] = []string{post.ID} } else { - threadToPosts[post.ThreadID] = append(threadToPosts[post.ThreadID], post.ID) + threadToPosts[post.ParentID] = append(threadToPosts[post.ParentID], post.ID) } } @@ -26,7 +30,7 @@ func main() { thread, err := arn.GetThread(threadID) arn.PanicOnError(err) - thread.Posts = posts + thread.PostIDs = posts thread.Save() } }