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 branch 'feat/1.1.0/sql' into test
aichy126b3bc6eed4de5
diff --cc internal/migrations/v13.goindex 278b1826,ddef599c..e69de29b--- a/internal/migrations/v13.go+++ b/internal/migrations/v13.go@@@ -1,34 -1,43 +1,0 @@@--package migrations----import (- "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 addGravatarBaseURL(x *xorm.Engine) error {- usersSiteInfo := &entity.SiteInfo{- Type: constant.SiteTypeUsers,-func updateQuestionCount(x *xorm.Engine) error {- //search all answers- answers := make([]entity.Answer, 0)- err := x.Find(&answers, &entity.Answer{Status: entity.AnswerStatusAvailable})- if err != nil {- return fmt.Errorf("get answers failed: %w", err)-- }- exist, err := x.Get(usersSiteInfo)- questionAnswerCount := make(map[string]int)- for _, answer := range answers {- _, ok := questionAnswerCount[answer.QuestionID]- if !ok {- questionAnswerCount[answer.QuestionID] = 1- } else {- questionAnswerCount[answer.QuestionID]++- }- }- questionList := make([]entity.Question, 0)- err = x.Find(&questionList, &entity.Question{})-- if err != nil {- return fmt.Errorf("get config failed: %w", err)- return fmt.Errorf("get questions 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)- for _, item := range questionList {- _, ok := questionAnswerCount[item.ID]- if ok {- item.AnswerCount = questionAnswerCount[item.ID]- if _, err = x.Update(item, &entity.Question{ID: item.ID}); err != nil {- log.Errorf("update %+v config failed: %s", item, err)- return fmt.Errorf("update question failed: %w", err)- }-- }-- }-- return nil--}