checkpoint before threading post migration

This commit is contained in:
Ross Trottier 2024-05-24 15:42:17 -06:00
parent 93f5c70236
commit e473c0e522

View File

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