A Q&A platform software for teams at any scales. Whether it's a community forum, help center, or knowledge management platform, you can always count on Apache Answer.
Merge conflict
aichy12644e0177661ea
diff --git a/internal/migrations/migrations.go b/internal/migrations/migrations.goindex 8d8268ca..c2b2f432 100644--- a/internal/migrations/migrations.go+++ b/internal/migrations/migrations.go@@ -62,7 +62,7 @@ var migrations = []Migration{NewMigration("add login limitations", addLoginLimitations, true),NewMigration("update user pin hide features", updateRolePinAndHideFeatures, true),NewMigration("update question post time", updateQuestionPostTime, true),- NewMigration("add gravatar base url", addGravatarBaseURL, false),+ NewMigration("add gravatar base url", updateCount, false),}// GetCurrentDBVersion returns the current db versiondiff --git a/internal/migrations/v13.go b/internal/migrations/v13.goindex 0f18cd98..1fefb840 100644--- a/internal/migrations/v13.go+++ b/internal/migrations/v13.go@@ -1,25 +1,52 @@package migrationsimport (+ "encoding/json""fmt"+ "github.com/answerdev/answer/internal/base/constant""github.com/answerdev/answer/internal/entity"+ "github.com/answerdev/answer/internal/schema""github.com/segmentfault/pacman/log""xorm.io/xorm")func updateCount(x *xorm.Engine) error {- // updateQuestionCount(x)- // updateTagCount(x)- // updateUserQuestionCount(x)+ addGravatarBaseURL(x)+ updateQuestionCount(x)+ updateTagCount(x)+ updateUserQuestionCount(x)updateUserAnswerCount(x)return nil}+func addGravatarBaseURL(x *xorm.Engine) error {+ usersSiteInfo := &entity.SiteInfo{+ Type: constant.SiteTypeUsers,+ }+ exist, err := x.Get(usersSiteInfo)+ if err != nil {+ return fmt.Errorf("get config failed: %w", err)+ }+ if exist {+ content := &schema.SiteUsersReq{}+ _ = json.Unmarshal([]byte(usersSiteInfo.Content), content)+ content.GravatarBaseURL = "https://www.gravatar.com/avatar/"+ data, _ := json.Marshal(content)+ usersSiteInfo.Content = string(data)++ _, err = x.ID(usersSiteInfo.ID).Cols("content").Update(usersSiteInfo)+ if err != nil {+ return fmt.Errorf("update site info failed: %w", err)+ }+ }+ return nil+}+func updateQuestionCount(x *xorm.Engine) error {//question answer countanswers := make([]entity.Answer, 0)- err = x.Find(&answers, &entity.Answer{Status: entity.AnswerStatusAvailable})+ err := x.Find(&answers, &entity.Answer{Status: entity.AnswerStatusAvailable})if err != nil {return fmt.Errorf("get answers failed: %w", err)}