diff --git a/services/migration/migrate-posts.go b/services/migration/migrate-posts.go index f9f6de4..84c46d9 100644 --- a/services/migration/migrate-posts.go +++ b/services/migration/migrate-posts.go @@ -27,6 +27,7 @@ func (migration MigratePosts) Execute() []PostResult { if err != nil { panic("Could not migrate posts:" + err.Error()) } + slowtwitchPostIdsForMigration := getPostIdsThatNeedMigration(slowtwitchPostIds, migratedPostIds) //get wordpress tag data, there are only 3 tags := []string{"swim", "bike", "run"} @@ -35,7 +36,6 @@ func (migration MigratePosts) Execute() []PostResult { panic("Could not migrate posts due to tags not found:" + wpTagErr.Error()) } - slowtwitchPostIdsForMigration := getPostIdsThatNeedMigration(slowtwitchPostIds, migratedPostIds) var postResults []PostResult for _, postId := range slowtwitchPostIdsForMigration { errorMessage := "" @@ -231,6 +231,12 @@ func (migration MigratePosts) Execute() []PostResult { postResults = append(postResults, postResult) } // Update related posts once work is done + updatePostRelationships(postResults, migration) + + return postResults +} + +func updatePostRelationships(postResults []PostResult, migration MigratePosts) { for _, postResult := range postResults { if postResult.IsSuccess { var relatedWordpressIds []int @@ -261,8 +267,6 @@ func (migration MigratePosts) Execute() []PostResult { } } } - - return postResults } func getPostIdsThatNeedMigration(slowtwitchPostIds, migratedPostIds []int) []int {