Skip to content

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.

fix: dedup questions in GetQuestionPage

hgaold8ab25d5653d
diff --git a/internal/repo/question/question_repo.go b/internal/repo/question/question_repo.go
index d13cf193..3935e610 100644
--- a/internal/repo/question/question_repo.go
+++ b/internal/repo/question/question_repo.go
@@ -404,6 +404,7 @@ func (qr *questionRepo) GetQuestionPage(ctx context.Context, page, pageSize int,
if showPending {
status = append(status, entity.QuestionStatusPending)
}
+ session.Select("question.*")
session.In("question.status", status)
if len(tagIDs) > 0 {
session.Join("LEFT", "tag_rel", "question.id = tag_rel.object_id")
@@ -442,6 +443,7 @@ func (qr *questionRepo) GetQuestionPage(ctx context.Context, page, pageSize int,
session.OrderBy("question.pin DESC, question.linked_count DESC, question.updated_at DESC")
}
+ session.GroupBy("question.id")
total, err = pager.Help(page, pageSize, &questionList, &entity.Question{}, session)
if err != nil {
err = errors.InternalServer(reason.DatabaseError).WithError(err).WithStack()