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(hot): change frequent to hot
kumfo795febe0ee68
diff --git a/cmd/wire_gen.go b/cmd/wire_gen.goindex e7ff464c..e9967e83 100644--- a/cmd/wire_gen.go+++ b/cmd/wire_gen.go@@ -194,7 +194,7 @@ func initApplication(debug bool, serverConf *conf.Server, dbConf *data.Database,externalNotificationService := notification.NewExternalNotificationService(dataData, userNotificationConfigRepo, followRepo, emailService, userRepo, externalNotificationQueueService, userExternalLoginRepo, siteInfoCommonService)reviewRepo := review.NewReviewRepo(dataData)reviewService := review2.NewReviewService(reviewRepo, objService, userCommon, userRepo, questionRepo, answerRepo, userRoleRelService, externalNotificationQueueService, tagCommonService, notificationQueueService, siteInfoCommonService)- questionService := content.NewQuestionService(questionRepo, tagCommonService, questionCommon, userCommon, userRepo, userRoleRelService, revisionService, metaCommonService, collectionCommon, answerActivityService, emailService, notificationQueueService, externalNotificationQueueService, activityQueueService, siteInfoCommonService, externalNotificationService, reviewService, configService)+ questionService := content.NewQuestionService(questionRepo, answerRepo, tagCommonService, questionCommon, userCommon, userRepo, userRoleRelService, revisionService, metaCommonService, collectionCommon, answerActivityService, emailService, notificationQueueService, externalNotificationQueueService, activityQueueService, siteInfoCommonService, externalNotificationService, reviewService, configService)answerService := content.NewAnswerService(answerRepo, questionRepo, questionCommon, userCommon, collectionCommon, userRepo, revisionService, answerActivityService, answerCommon, voteRepo, emailService, userRoleRelService, notificationQueueService, externalNotificationQueueService, activityQueueService, reviewService)reportHandle := report_handle.NewReportHandle(questionService, answerService, commentService)reportService := report2.NewReportService(reportRepo, objService, userCommon, answerRepo, questionRepo, commentCommonRepo, reportHandle, configService)diff --git a/docs/docs.go b/docs/docs.goindex ec6aafce..b734123f 100644--- a/docs/docs.go+++ b/docs/docs.go@@ -8833,7 +8833,7 @@ const docTemplate = `{"enum": ["newest","active",- "frequent",+ "hot","score","unanswered"]diff --git a/i18n/af_ZA.yaml b/i18n/af_ZA.yamlindex 8227460c..efef6068 100644--- a/i18n/af_ZA.yaml+++ b/i18n/af_ZA.yaml@@ -858,7 +858,7 @@ ui:answers: Answersnewest: Newestactive: Active- frequent: Frequent+ hot: Hotscore: Scoreunanswered: Unansweredmodified: modifieddiff --git a/i18n/ar_SA.yaml b/i18n/ar_SA.yamlindex a6c48ffa..c91f56b0 100644--- a/i18n/ar_SA.yaml+++ b/i18n/ar_SA.yaml@@ -858,7 +858,7 @@ ui:answers: Answersnewest: Newestactive: Active- frequent: Frequent+ hot: Hotscore: Scoreunanswered: Unansweredmodified: modifieddiff --git a/i18n/az_AZ.yaml b/i18n/az_AZ.yamlindex 2252bdcd..a667823b 100644--- a/i18n/az_AZ.yaml+++ b/i18n/az_AZ.yaml@@ -850,7 +850,7 @@ ui:answers: Answersnewest: Newestactive: Active- frequent: Frequent+ hot: Hotscore: Scoreunanswered: Unansweredmodified: modifieddiff --git a/i18n/bal_BA.yaml b/i18n/bal_BA.yamlindex 2252bdcd..a667823b 100644--- a/i18n/bal_BA.yaml+++ b/i18n/bal_BA.yaml@@ -850,7 +850,7 @@ ui:answers: Answersnewest: Newestactive: Active- frequent: Frequent+ hot: Hotscore: Scoreunanswered: Unansweredmodified: modifieddiff --git a/i18n/ban_ID.yaml b/i18n/ban_ID.yamlindex 2252bdcd..a667823b 100644--- a/i18n/ban_ID.yaml+++ b/i18n/ban_ID.yaml@@ -850,7 +850,7 @@ ui:answers: Answersnewest: Newestactive: Active- frequent: Frequent+ hot: Hotscore: Scoreunanswered: Unansweredmodified: modifieddiff --git a/i18n/bn_BD.yaml b/i18n/bn_BD.yamlindex 2252bdcd..a667823b 100644--- a/i18n/bn_BD.yaml+++ b/i18n/bn_BD.yaml@@ -850,7 +850,7 @@ ui:answers: Answersnewest: Newestactive: Active- frequent: Frequent+ hot: Hotscore: Scoreunanswered: Unansweredmodified: modifieddiff --git a/i18n/bs_BA.yaml b/i18n/bs_BA.yamlindex 2252bdcd..a667823b 100644--- a/i18n/bs_BA.yaml+++ b/i18n/bs_BA.yaml@@ -850,7 +850,7 @@ ui:answers: Answersnewest: Newestactive: Active- frequent: Frequent+ hot: Hotscore: Scoreunanswered: Unansweredmodified: modifieddiff --git a/i18n/ca_ES.yaml b/i18n/ca_ES.yamlindex a6c48ffa..c91f56b0 100644--- a/i18n/ca_ES.yaml+++ b/i18n/ca_ES.yaml@@ -858,7 +858,7 @@ ui:answers: Answersnewest: Newestactive: Active- frequent: Frequent+ hot: Hotscore: Scoreunanswered: Unansweredmodified: modifieddiff --git a/i18n/cs_CZ.yaml b/i18n/cs_CZ.yamlindex 4414f945..00f9f990 100644--- a/i18n/cs_CZ.yaml+++ b/i18n/cs_CZ.yaml@@ -1249,7 +1249,7 @@ ui:answers: Answersnewest: Newestactive: Active- frequent: Frequent+ hot: Hotscore: Scoreunanswered: Unansweredmodified: modifieddiff --git a/i18n/cy_GB.yaml b/i18n/cy_GB.yamlindex b3c696fa..833cb090 100644--- a/i18n/cy_GB.yaml+++ b/i18n/cy_GB.yaml@@ -1249,7 +1249,7 @@ ui:answers: Answersnewest: Newestactive: Active- frequent: Frequent+ hot: Hotscore: Scoreunanswered: Unansweredmodified: modifieddiff --git a/i18n/da_DK.yaml b/i18n/da_DK.yamlindex 85ead2ab..fe4bf6ab 100644--- a/i18n/da_DK.yaml+++ b/i18n/da_DK.yaml@@ -1249,7 +1249,7 @@ ui:answers: Answersnewest: Newestactive: Active- frequent: Frequent+ hot: Hotscore: Scoreunanswered: Unansweredmodified: modifieddiff --git a/i18n/de_DE.yaml b/i18n/de_DE.yamlindex c82a4255..c8dac06c 100644--- a/i18n/de_DE.yaml+++ b/i18n/de_DE.yaml@@ -1249,7 +1249,7 @@ ui:answers: Antwortennewest: Neuesteactive: Aktiv- frequent: Häufig+ hot: Hotscore: Punktzahlunanswered: Unbeantwortetmodified: geändertdiff --git a/i18n/el_GR.yaml b/i18n/el_GR.yamlindex a6c48ffa..c91f56b0 100644--- a/i18n/el_GR.yaml+++ b/i18n/el_GR.yaml@@ -858,7 +858,7 @@ ui:answers: Answersnewest: Newestactive: Active- frequent: Frequent+ hot: Hotscore: Scoreunanswered: Unansweredmodified: modifieddiff --git a/i18n/es_ES.yaml b/i18n/es_ES.yamlindex f1696bce..551f80e0 100644--- a/i18n/es_ES.yaml+++ b/i18n/es_ES.yaml@@ -1249,7 +1249,7 @@ ui:answers: Respuestasnewest: Más recienteactive: Activo- frequent: Frecuente+ hot: Hotscore: Puntuaciónunanswered: Sin respuestamodified: modificadadiff --git a/i18n/fa_IR.yaml b/i18n/fa_IR.yamlindex e84840d3..f6d8c47c 100644--- a/i18n/fa_IR.yaml+++ b/i18n/fa_IR.yaml@@ -1249,7 +1249,7 @@ ui:answers: پاسخ هاnewest: جدیدترینactive: فعال- frequent: پرتکرار+ hot: Hotscore: امتیازunanswered: بدون پاسخmodified: تغییر یافتهdiff --git a/i18n/fi_FI.yaml b/i18n/fi_FI.yamlindex a6c48ffa..c91f56b0 100644--- a/i18n/fi_FI.yaml+++ b/i18n/fi_FI.yaml@@ -858,7 +858,7 @@ ui:answers: Answersnewest: Newestactive: Active- frequent: Frequent+ hot: Hotscore: Scoreunanswered: Unansweredmodified: modifieddiff --git a/i18n/fr_FR.yaml b/i18n/fr_FR.yamlindex 4adf0807..7fab3d3b 100644--- a/i18n/fr_FR.yaml+++ b/i18n/fr_FR.yaml@@ -1249,7 +1249,7 @@ ui:answers: Réponsesnewest: Les plus récentsactive: Actif- frequent: Fréquents+ hot: Hotscore: Scoreunanswered: Sans réponsemodified: modifiédiff --git a/i18n/he_IL.yaml b/i18n/he_IL.yamlindex a6c48ffa..c91f56b0 100644--- a/i18n/he_IL.yaml+++ b/i18n/he_IL.yaml@@ -858,7 +858,7 @@ ui:answers: Answersnewest: Newestactive: Active- frequent: Frequent+ hot: Hotscore: Scoreunanswered: Unansweredmodified: modifieddiff --git a/i18n/hi_IN.yaml b/i18n/hi_IN.yamlindex 85ead2ab..fe4bf6ab 100644--- a/i18n/hi_IN.yaml+++ b/i18n/hi_IN.yaml@@ -1249,7 +1249,7 @@ ui:answers: Answersnewest: Newestactive: Active- frequent: Frequent+ hot: Hotscore: Scoreunanswered: Unansweredmodified: modifieddiff --git a/i18n/hu_HU.yaml b/i18n/hu_HU.yamlindex a6c48ffa..c91f56b0 100644--- a/i18n/hu_HU.yaml+++ b/i18n/hu_HU.yaml@@ -858,7 +858,7 @@ ui:answers: Answersnewest: Newestactive: Active- frequent: Frequent+ hot: Hotscore: Scoreunanswered: Unansweredmodified: modifieddiff --git a/i18n/hy_AM.yaml b/i18n/hy_AM.yamlindex 2252bdcd..a667823b 100644--- a/i18n/hy_AM.yaml+++ b/i18n/hy_AM.yaml@@ -850,7 +850,7 @@ ui:answers: Answersnewest: Newestactive: Active- frequent: Frequent+ hot: Hotscore: Scoreunanswered: Unansweredmodified: modifieddiff --git a/i18n/id_ID.yaml b/i18n/id_ID.yamlindex 4dead453..2053e9ea 100644--- a/i18n/id_ID.yaml+++ b/i18n/id_ID.yaml@@ -1249,7 +1249,7 @@ ui:answers: Jawabannewest: Terbaruactive: Aktif- frequent: Sering+ hot: Hotscore: Nilaiunanswered: Belum dijawabmodified: diubahdiff --git a/i18n/it_IT.yaml b/i18n/it_IT.yamlindex 9b39853a..4a33c69b 100644--- a/i18n/it_IT.yaml+++ b/i18n/it_IT.yaml@@ -1249,7 +1249,7 @@ ui:answers: Rispostenewest: Più recentiactive: Attivo- frequent: Frequenti+ hot: Hotscore: Punteggiounanswered: Senza rispostamodified: Modificatodiff --git a/i18n/ja_JP.yaml b/i18n/ja_JP.yamlindex 045b06bf..db7175d6 100644--- a/i18n/ja_JP.yaml+++ b/i18n/ja_JP.yaml@@ -1249,7 +1249,7 @@ ui:answers: 回答newest: 最新active: 有効- frequent: 頻繁+ hot: Hotscore: スコアunanswered: 未回答modified: 修正済みdiff --git a/i18n/ko_KR.yaml b/i18n/ko_KR.yamlindex 9e6f3571..3778d5c7 100644--- a/i18n/ko_KR.yaml+++ b/i18n/ko_KR.yaml@@ -1249,7 +1249,7 @@ ui:answers: 답변newest: 최신순active: 활성순- frequent: 자주 본 질문+ hot: Hotscore: 평점순unanswered: 답변이 없는 질문modified: 수정됨diff --git a/i18n/nl_NL.yaml b/i18n/nl_NL.yamlindex a6c48ffa..c91f56b0 100644--- a/i18n/nl_NL.yaml+++ b/i18n/nl_NL.yaml@@ -858,7 +858,7 @@ ui:answers: Answersnewest: Newestactive: Active- frequent: Frequent+ hot: Hotscore: Scoreunanswered: Unansweredmodified: modifieddiff --git a/i18n/no_NO.yaml b/i18n/no_NO.yamlindex a6c48ffa..c91f56b0 100644--- a/i18n/no_NO.yaml+++ b/i18n/no_NO.yaml@@ -858,7 +858,7 @@ ui:answers: Answersnewest: Newestactive: Active- frequent: Frequent+ hot: Hotscore: Scoreunanswered: Unansweredmodified: modifieddiff --git a/i18n/pl_PL.yaml b/i18n/pl_PL.yamlindex edcf60c4..d43b1a6b 100644--- a/i18n/pl_PL.yaml+++ b/i18n/pl_PL.yaml@@ -1249,7 +1249,7 @@ ui:answers: Odpowiedzinewest: Najnowszeactive: Aktywne- frequent: Częste+ hot: Hotscore: Ocenaunanswered: Bez odpowiedzimodified: zmodyfikowanediff --git a/i18n/pt_BR.yaml b/i18n/pt_BR.yamlindex 11b8920c..4210d5bd 100644--- a/i18n/pt_BR.yaml+++ b/i18n/pt_BR.yaml@@ -855,7 +855,7 @@ ui:answers: Respostasnewest: Mais recenteactive: Ativo- frequent: Frequente+ hot: Hotscore: Pontuaçãounanswered: Não Respondidomodified: modificadodiff --git a/i18n/pt_PT.yaml b/i18n/pt_PT.yamlindex a7f3fedd..b825f6e9 100644--- a/i18n/pt_PT.yaml+++ b/i18n/pt_PT.yaml@@ -1249,7 +1249,7 @@ ui:answers: Respostasnewest: Mais recenteactive: Ativo- frequent: Frequente+ hot: Hotscore: Pontuaçãounanswered: Não Respondidomodified: modificadodiff --git a/i18n/ro_RO.yaml b/i18n/ro_RO.yamlindex 20599ec5..db6ccbbd 100644--- a/i18n/ro_RO.yaml+++ b/i18n/ro_RO.yaml@@ -1249,7 +1249,7 @@ ui:answers: Răspunsurinewest: Cele mai noiactive: Activ- frequent: Frecvent+ hot: Hotscore: Scorunanswered: Fără răspunsmodified: modificatdiff --git a/i18n/ru_RU.yaml b/i18n/ru_RU.yamlindex d9d01648..d9f03407 100644--- a/i18n/ru_RU.yaml+++ b/i18n/ru_RU.yaml@@ -1249,7 +1249,7 @@ ui:answers: Ответыnewest: Последниеactive: Активные- frequent: Популярные+ hot: Hotscore: Оценкаunanswered: Без ответаmodified: изменёнdiff --git a/i18n/sk_SK.yaml b/i18n/sk_SK.yamlindex 3b4731d2..ffe0f7f6 100644--- a/i18n/sk_SK.yaml+++ b/i18n/sk_SK.yaml@@ -1249,7 +1249,7 @@ ui:answers: Odpovedenewest: Najnovšieactive: Aktívne- frequent: Časté+ hot: Hotscore: Skóreunanswered: Nezodpovedanémodified: upravenédiff --git a/i18n/sq_AL.yaml b/i18n/sq_AL.yamlindex 2252bdcd..a667823b 100644--- a/i18n/sq_AL.yaml+++ b/i18n/sq_AL.yaml@@ -850,7 +850,7 @@ ui:answers: Answersnewest: Newestactive: Active- frequent: Frequent+ hot: Hotscore: Scoreunanswered: Unansweredmodified: modifieddiff --git a/i18n/sr_SP.yaml b/i18n/sr_SP.yamlindex a6c48ffa..c91f56b0 100644--- a/i18n/sr_SP.yaml+++ b/i18n/sr_SP.yaml@@ -858,7 +858,7 @@ ui:answers: Answersnewest: Newestactive: Active- frequent: Frequent+ hot: Hotscore: Scoreunanswered: Unansweredmodified: modifieddiff --git a/i18n/sv_SE.yaml b/i18n/sv_SE.yamlindex 99c3494b..a0f992c5 100644--- a/i18n/sv_SE.yaml+++ b/i18n/sv_SE.yaml@@ -1249,7 +1249,7 @@ ui:answers: Answersnewest: Newestactive: Active- frequent: Frequent+ hot: Hotscore: Scoreunanswered: Unansweredmodified: modifieddiff --git a/i18n/te_IN.yaml b/i18n/te_IN.yamlindex 650cbfc1..e0a42ddd 100644--- a/i18n/te_IN.yaml+++ b/i18n/te_IN.yaml@@ -1249,7 +1249,7 @@ ui:answers: Answersnewest: Newestactive: Active- frequent: Frequent+ hot: Hotscore: Scoreunanswered: Unansweredmodified: modifieddiff --git a/i18n/tr_TR.yaml b/i18n/tr_TR.yamlindex d3d0d959..f7ba5a89 100644--- a/i18n/tr_TR.yaml+++ b/i18n/tr_TR.yaml@@ -1249,7 +1249,7 @@ ui:answers: Answersnewest: Newestactive: Active- frequent: Frequent+ hot: Hotscore: Scoreunanswered: Unansweredmodified: modifieddiff --git a/i18n/uk_UA.yaml b/i18n/uk_UA.yamlindex ef15bc12..4634d2cd 100644--- a/i18n/uk_UA.yaml+++ b/i18n/uk_UA.yaml@@ -1249,7 +1249,7 @@ ui:answers: Відповідіnewest: Найновішіactive: Активні- frequent: Frequent+ hot: Hotscore: Оцінкаunanswered: Без відповідейmodified: modifieddiff --git a/i18n/vi_VN.yaml b/i18n/vi_VN.yamlindex 1a286506..1e883778 100644--- a/i18n/vi_VN.yaml+++ b/i18n/vi_VN.yaml@@ -1249,7 +1249,7 @@ ui:answers: Answersnewest: Newestactive: Active- frequent: Frequent+ hot: Hotscore: Scoreunanswered: Unansweredmodified: modifieddiff --git a/i18n/zh_TW.yaml b/i18n/zh_TW.yamlindex 364f8c02..1f2db470 100644--- a/i18n/zh_TW.yaml+++ b/i18n/zh_TW.yaml@@ -1249,7 +1249,7 @@ ui:answers: 回答newest: 最新的active: 活躍的- frequent: 瀏覽量+ hot: 熱門score: 評分unanswered: 未回答modified: 修改於diff --git a/internal/base/cron/cron.go b/internal/base/cron/cron.goindex b7b05c26..0d08e50f 100644--- a/internal/base/cron/cron.go+++ b/internal/base/cron/cron.go@@ -59,5 +59,15 @@ func (s *ScheduledTaskManager) Run() {if err != nil {log.Error(err)}++ _, err = c.AddFunc("0 */1 * * *", func() {+ ctx := context.Background()+ fmt.Println("refresh hottest cron execution")+ s.questionService.RefreshHottestCron(ctx)+ })+ if err != nil {+ log.Error(err)+ }+c.Start()}diff --git a/internal/entity/question_entity.go b/internal/entity/question_entity.goindex 280cc670..1931282c 100644--- a/internal/entity/question_entity.go+++ b/internal/entity/question_entity.go@@ -66,6 +66,7 @@ type Question struct {UniqueViewCount int `xorm:"not null default 0 INT(11) unique_view_count"`VoteCount int `xorm:"not null default 0 INT(11) vote_count"`AnswerCount int `xorm:"not null default 0 INT(11) answer_count"`+ HotScore int `xorm:"not null default 0 INT(11) hot_score"`CollectionCount int `xorm:"not null default 0 INT(11) collection_count"`FollowCount int `xorm:"not null default 0 INT(11) follow_count"`AcceptedAnswerID string `xorm:"not null default 0 BIGINT(20) accepted_answer_id"`diff --git a/internal/repo/answer/answer_repo.go b/internal/repo/answer/answer_repo.goindex 3edbec34..79dac140 100644--- a/internal/repo/answer/answer_repo.go+++ b/internal/repo/answer/answer_repo.go@@ -430,6 +430,17 @@ func (ar *answerRepo) AdminSearchList(ctx context.Context, req *schema.AdminAnswreturn resp, total, nil}+// SumVotesByQuestionID sum votes by question id+func (ar *answerRepo) SumVotesByQuestionID(ctx context.Context, questionID string) (float64, error) {+ questionID = uid.DeShortID(questionID)+ var resp entity.Answer+ count, err := ar.data.DB.Context(ctx).Where("question_id = ? and status = ?", questionID, entity.AnswerStatusAvailable).Sum(&resp, "vote_count")+ if err != nil {+ return count, errors.InternalServer(reason.DatabaseError).WithError(err).WithStack()+ }+ return count, nil+}+// updateSearch update search, if search plugin not enable, do nothingfunc (ar *answerRepo) updateSearch(ctx context.Context, answerID string) (err error) {answerID = uid.DeShortID(answerID)diff --git a/internal/repo/question/question_repo.go b/internal/repo/question/question_repo.goindex 4dcfc8f8..5a683af7 100644--- a/internal/repo/question/question_repo.go+++ b/internal/repo/question/question_repo.go@@ -380,8 +380,8 @@ func (qr *questionRepo) GetQuestionPage(ctx context.Context, page, pageSize int,}session.And("question.post_update_time > ?", time.Now().AddDate(0, 0, -90))session.OrderBy("question.pin desc,question.post_update_time DESC, question.updated_at DESC")- case "frequent":- session.OrderBy("question.pin desc,question.view_count DESC")+ case "hot":+ session.OrderBy("question.pin desc,question.hot_score DESC")case "score":session.OrderBy("question.pin desc,question.vote_count DESC, question.view_count DESC")case "unanswered":diff --git a/internal/schema/question_schema.go b/internal/schema/question_schema.goindex f915d5ea..a4c6ee8c 100644--- a/internal/schema/question_schema.go+++ b/internal/schema/question_schema.go@@ -343,16 +343,19 @@ type UserQuestionInfo struct {const (QuestionOrderCondNewest = "newest"QuestionOrderCondActive = "active"- QuestionOrderCondFrequent = "frequent"+ QuestionOrderCondHot = "hot"QuestionOrderCondScore = "score"QuestionOrderCondUnanswered = "unanswered"++ // HotInDays limit max days of the hottest question+ HotInDays = 90)// QuestionPageReq query questions pagetype QuestionPageReq struct {Page int `validate:"omitempty,min=1" form:"page"`PageSize int `validate:"omitempty,min=1" form:"page_size"`- OrderCond string `validate:"omitempty,oneof=newest active frequent score unanswered" form:"order"`+ OrderCond string `validate:"omitempty,oneof=newest active hot score unanswered" form:"order"`Tag string `validate:"omitempty,gt=0,lte=100" form:"tag"`Username string `validate:"omitempty,gt=0,lte=100" form:"username"`InDays int `validate:"omitempty,min=1" form:"in_days"`@@ -475,7 +478,7 @@ type AdminUpdateQuestionStatusReq struct {type PersonalQuestionPageReq struct {Page int `validate:"omitempty,min=1" form:"page"`PageSize int `validate:"omitempty,min=1" form:"page_size"`- OrderCond string `validate:"omitempty,oneof=newest active frequent score unanswered" form:"order"`+ OrderCond string `validate:"omitempty,oneof=newest active hot score unanswered" form:"order"`Username string `validate:"omitempty,gt=0,lte=100" form:"username"`LoginUserID string `json:"-"`IsAdmin bool `json:"-"`@@ -484,7 +487,7 @@ type PersonalQuestionPageReq struct {type PersonalAnswerPageReq struct {Page int `validate:"omitempty,min=1" form:"page"`PageSize int `validate:"omitempty,min=1" form:"page_size"`- OrderCond string `validate:"omitempty,oneof=newest active frequent score unanswered" form:"order"`+ OrderCond string `validate:"omitempty,oneof=newest active hot score unanswered" form:"order"`Username string `validate:"omitempty,gt=0,lte=100" form:"username"`LoginUserID string `json:"-"`IsAdmin bool `json:"-"`diff --git a/internal/service/answer_common/answer.go b/internal/service/answer_common/answer.goindex af2be2f0..1517b22d 100644--- a/internal/service/answer_common/answer.go+++ b/internal/service/answer_common/answer.go@@ -49,6 +49,7 @@ type AnswerRepo interface {UpdateAnswerStatus(ctx context.Context, answerID string, status int) (err error)GetAnswerCount(ctx context.Context) (count int64, err error)RemoveAllUserAnswer(ctx context.Context, userID string) (err error)+ SumVotesByQuestionID(ctx context.Context, questionID string) (float64, error)}// AnswerCommon user servicediff --git a/internal/service/content/question_hottest_service.go b/internal/service/content/question_hottest_service.gonew file mode 100644index 00000000..6a37d3b3--- /dev/null+++ b/internal/service/content/question_hottest_service.go@@ -0,0 +1,89 @@+/*+ * Licensed to the Apache Software Foundation (ASF) under one+ * or more contributor license agreements. See the NOTICE file+ * distributed with this work for additional information+ * regarding copyright ownership. The ASF licenses this file+ * to you under the Apache License, Version 2.0 (the+ * "License"); you may not use this file except in compliance+ * with the License. You may obtain a copy of the License at+ *+ * http://www.apache.org/licenses/LICENSE-2.0+ *+ * Unless required by applicable law or agreed to in writing,+ * software distributed under the License is distributed on an+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY+ * KIND, either express or implied. See the License for the+ * specific language governing permissions and limitations+ * under the License.+ */++package content++import (+ "context"+ "github.com/apache/incubator-answer/internal/entity"+ "github.com/apache/incubator-answer/internal/schema"+ "github.com/segmentfault/pacman/log"+ "math"+ "time"+)++func (q *QuestionService) RefreshHottestCron(ctx context.Context) {++ var (+ page = 1+ pageSize = 100+ )++ for {+ questionList, _, err := q.questionRepo.GetQuestionPage(+ ctx,+ page, pageSize,+ []string{},+ "", "newest",+ schema.HotInDays,+ false, false)+ if err != nil {+ return+ }++ for _, question := range questionList {+ updatedAt := question.UpdatedAt.Unix()+ if updatedAt < 0 {+ updatedAt = question.CreatedAt.Unix()+ }++ qAgeInHours := (time.Now().Unix() - question.CreatedAt.Unix()) / 3600+ qUpdated := (time.Now().Unix() - updatedAt) / 3600++ aScores, err := q.answerRepo.SumVotesByQuestionID(ctx, question.ID)+ if err != nil {+ aScores = 0+ }++ score := q.getScore(float64(question.ViewCount), float64(question.AnswerCount), float64(question.VoteCount), aScores, float64(qAgeInHours), float64(qUpdated))+ if score < 0 {+ score = 0+ }++ questioninfo := &entity.Question{}+ questioninfo.ID = question.ID+ questioninfo.HotScore = int(math.Ceil(score * 10000))+ err = q.questionRepo.UpdateQuestion(ctx, questioninfo, []string{"hot_score"})+ if err != nil {+ log.Error("update question hot score error,question ID:", question.ID, " error: ", err)+ }+ }++ if len(questionList) < pageSize {+ break+ }+ page+++ }+}++func (q *QuestionService) getScore(qViews, qAnswers, qScore, aScores, qAgeInHours, qUpdated float64) (score float64) {+ score = ((math.Log(qViews) * 4) + ((qAnswers * qScore) / 5) + aScores) /+ math.Pow(((qAgeInHours+1)-((qAgeInHours-qUpdated)/2)), 1.5)+ return score+}diff --git a/internal/service/content/question_service.go b/internal/service/content/question_service.goindex e11a608b..6d8b37ba 100644--- a/internal/service/content/question_service.go+++ b/internal/service/content/question_service.go@@ -22,6 +22,7 @@ package contentimport ("encoding/json""fmt"+ answercommon "github.com/apache/incubator-answer/internal/service/answer_common""strings""time"@@ -65,6 +66,7 @@ import (// QuestionService user servicetype QuestionService struct {questionRepo questioncommon.QuestionRepo+ answerRepo answercommon.AnswerRepotagCommon *tagcommon.TagCommonServicequestioncommon *questioncommon.QuestionCommonuserCommon *usercommon.UserCommon@@ -86,6 +88,7 @@ type QuestionService struct {func NewQuestionService(questionRepo questioncommon.QuestionRepo,+ answerRepo answercommon.AnswerRepo,tagCommon *tagcommon.TagCommonService,questioncommon *questioncommon.QuestionCommon,userCommon *usercommon.UserCommon,@@ -106,6 +109,7 @@ func NewQuestionService() *QuestionService {return &QuestionService{questionRepo: questionRepo,+ answerRepo: answerRepo,tagCommon: tagCommon,questioncommon: questioncommon,userCommon: userCommon,@@ -1264,7 +1268,7 @@ func (qs *QuestionService) SimilarQuestion(ctx context.Context, questionID strintagNames = append(tagNames, tag.SlugName)}search := &schema.QuestionPageReq{}- search.OrderCond = "frequent"+ search.OrderCond = "hot"search.Page = 0search.PageSize = 6if len(tagNames) > 0 {@@ -1328,6 +1332,10 @@ func (qs *QuestionService) GetQuestionPage(ctx context.Context, req *schema.Quesreq.UserIDBeSearched = userinfo.ID}+ if req.OrderCond == schema.QuestionOrderCondHot {+ req.InDays = schema.HotInDays+ }+questionList, total, err := qs.questionRepo.GetQuestionPage(ctx, req.Page, req.PageSize,tagIDs, req.UserIDBeSearched, req.OrderCond, req.InDays, showHidden, req.ShowPending)if err != nil {