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.
feat: version upgrade add rank limiting condition
LinkinStar06d358438dad
diff --git a/cmd/answer/main.go b/cmd/answer/main.goindex 8d1481ba..cea99db9 100644--- a/cmd/answer/main.go+++ b/cmd/answer/main.go@@ -35,12 +35,12 @@ var (// @in header// @name Authorizationfunc main() {+ log.SetLogger(zap.NewLogger(+ log.ParseLevel(logLevel), zap.WithName("answer"), zap.WithPath(logPath), zap.WithCallerFullPath()))Execute()}func runApp() {- log.SetLogger(zap.NewLogger(- log.ParseLevel(logLevel), zap.WithName("answer"), zap.WithPath(logPath), zap.WithCallerFullPath()))c, err := conf.ReadConfig(cli.GetConfigFilePath())if err != nil {panic(err)diff --git a/internal/entity/config_entity.go b/internal/entity/config_entity.goindex 1d716a2d..361e7acc 100644--- a/internal/entity/config_entity.go+++ b/internal/entity/config_entity.go@@ -3,7 +3,7 @@ package entity// Config configtype Config struct {ID int `xorm:"not null pk autoincr INT(11) id"`- Key string `xorm:"unique VARCHAR(32) key"`+ Key string `xorm:"unique VARCHAR(128) key"`Value string `xorm:"TEXT value"`}diff --git a/internal/migrations/v3.go b/internal/migrations/v3.goindex 47dce2f2..2a252d0c 100644--- a/internal/migrations/v3.go+++ b/internal/migrations/v3.go@@ -4,11 +4,41 @@ import ("time""github.com/answerdev/answer/internal/entity"+ "github.com/segmentfault/pacman/log""xorm.io/xorm")func addActivityTimeline(x *xorm.Engine) error {+ // only increasing field length to 128+ type Config struct {+ Key string `xorm:"unique VARCHAR(128) key"`+ }+ if err := x.Sync(new(Config)); err != nil {+ return err+ }defaultConfigTable := []*entity.Config{+ {ID: 36, Key: "rank.question.add", Value: `1`},+ {ID: 37, Key: "rank.question.edit", Value: `200`},+ {ID: 38, Key: "rank.question.delete", Value: `0`},+ {ID: 39, Key: "rank.question.vote_up", Value: `15`},+ {ID: 40, Key: "rank.question.vote_down", Value: `125`},+ {ID: 41, Key: "rank.answer.add", Value: `1`},+ {ID: 42, Key: "rank.answer.edit", Value: `200`},+ {ID: 43, Key: "rank.answer.delete", Value: `0`},+ {ID: 44, Key: "rank.answer.accept", Value: `1`},+ {ID: 45, Key: "rank.answer.vote_up", Value: `15`},+ {ID: 46, Key: "rank.answer.vote_down", Value: `125`},+ {ID: 47, Key: "rank.comment.add", Value: `1`},+ {ID: 48, Key: "rank.comment.edit", Value: `1`},+ {ID: 49, Key: "rank.comment.delete", Value: `0`},+ {ID: 50, Key: "rank.report.add", Value: `1`},+ {ID: 51, Key: "rank.tag.add", Value: `1`},+ {ID: 52, Key: "rank.tag.edit", Value: `100`},+ {ID: 53, Key: "rank.tag.delete", Value: `0`},+ {ID: 54, Key: "rank.tag.synonym", Value: `20000`},+ {ID: 55, Key: "rank.link.url_limit", Value: `10`},+ {ID: 56, Key: "rank.vote.detail", Value: `0`},+{ID: 87, Key: "question.asked", Value: `0`},{ID: 88, Key: "question.closed", Value: `0`},{ID: 89, Key: "question.reopened", Value: `0`},@@ -29,6 +59,15 @@ func addActivityTimeline(x *xorm.Engine) error {{ID: 104, Key: "tag.rollback", Value: `0`},{ID: 105, Key: "tag.deleted", Value: `0`},{ID: 106, Key: "tag.undeleted", Value: `0`},++ {ID: 107, Key: "rank.comment.vote_up", Value: `1`},+ {ID: 108, Key: "rank.comment.vote_down", Value: `1`},+ {ID: 109, Key: "rank.question.edit_without_review", Value: `2000`},+ {ID: 110, Key: "rank.answer.edit_without_review", Value: `2000`},+ {ID: 111, Key: "rank.tag.edit_without_review", Value: `20000`},+ {ID: 112, Key: "rank.answer.audit", Value: `2000`},+ {ID: 113, Key: "rank.question.audit", Value: `2000`},+ {ID: 114, Key: "rank.tag.audit", Value: `20000`},}for _, c := range defaultConfigTable {exist, err := x.Get(&entity.Config{ID: c.ID, Key: c.Key})@@ -36,9 +75,14 @@ func addActivityTimeline(x *xorm.Engine) error {return err}if exist {+ if _, err = x.Update(c, &entity.Config{ID: c.ID, Key: c.Key}); err != nil {+ log.Errorf("update %+v config failed: %s", c, err)+ return err+ }continue}- if _, err := x.Insert(&entity.Config{ID: c.ID, Key: c.Key, Value: c.Value}); err != nil {+ if _, err = x.Insert(&entity.Config{ID: c.ID, Key: c.Key, Value: c.Value}); err != nil {+ log.Errorf("insert %+v config failed: %s", c, err)return err}}