This is an automated email from the ASF dual-hosted git repository.

linkinstar pushed a commit to branch dev
in repository https://gitbox.apache.org/repos/asf/incubator-answer.git


The following commit(s) were added to refs/heads/dev by this push:
     new 1e80adda fix: Old questions may continue to be showed in the front
1e80adda is described below

commit 1e80addaecd3924c3297359c5e56b09bddbf722a
Author: sy-records <[email protected]>
AuthorDate: Thu Jun 6 20:34:21 2024 +0800

    fix: Old questions may continue to be showed in the front
---
 internal/repo/question/question_repo.go | 4 ++++
 1 file changed, 4 insertions(+)

diff --git a/internal/repo/question/question_repo.go 
b/internal/repo/question/question_repo.go
index 29ab9c5d..4dcfc8f8 100644
--- a/internal/repo/question/question_repo.go
+++ b/internal/repo/question/question_repo.go
@@ -375,6 +375,10 @@ func (qr *questionRepo) GetQuestionPage(ctx 
context.Context, page, pageSize int,
        case "newest":
                session.OrderBy("question.pin desc,question.created_at DESC")
        case "active":
+               if inDays == 0 {
+                       session.And("question.created_at > ?", 
time.Now().AddDate(0, 0, -180))
+               }
+               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")

Reply via email to