feat(queued): add status:pending(quesiton/answer/comment),and change question status query
This commit is contained in:
@@ -28,6 +28,7 @@ const (
|
||||
|
||||
AnswerStatusAvailable = 1
|
||||
AnswerStatusDeleted = 10
|
||||
AnswerStatusPending = 11
|
||||
)
|
||||
|
||||
var AdminAnswerSearchStatus = map[string]int{
|
||||
|
||||
@@ -30,6 +30,7 @@ import (
|
||||
const (
|
||||
CommentStatusAvailable = 1
|
||||
CommentStatusDeleted = 10
|
||||
CommentStatusPending = 11
|
||||
)
|
||||
|
||||
// Comment comment
|
||||
|
||||
@@ -27,6 +27,7 @@ const (
|
||||
QuestionStatusAvailable = 1
|
||||
QuestionStatusClosed = 2
|
||||
QuestionStatusDeleted = 10
|
||||
QuestionStatusPending = 11
|
||||
QuestionUnPin = 1
|
||||
QuestionPin = 2
|
||||
QuestionShow = 1
|
||||
|
||||
@@ -24,6 +24,7 @@ import (
|
||||
"encoding/json"
|
||||
"fmt"
|
||||
"time"
|
||||
"xorm.io/builder"
|
||||
|
||||
"github.com/apache/incubator-answer/internal/base/constant"
|
||||
"github.com/apache/incubator-answer/internal/entity"
|
||||
@@ -184,7 +185,7 @@ func updateTagCount(ctx context.Context, x *xorm.Engine) error {
|
||||
questionsHideMap[item.ObjectID] = false
|
||||
}
|
||||
questionList := make([]QuestionV13, 0)
|
||||
err = x.Context(ctx).In("id", questionIDs).In("question.status", []int{entity.QuestionStatusAvailable, entity.QuestionStatusClosed}).Find(&questionList, &QuestionV13{})
|
||||
err = x.Context(ctx).In("id", questionIDs).And(builder.Lt{"question.status": entity.QuestionStatusDeleted}).Find(&questionList, &QuestionV13{})
|
||||
if err != nil {
|
||||
return fmt.Errorf("get questions failed: %w", err)
|
||||
}
|
||||
@@ -256,7 +257,7 @@ func updateTagCount(ctx context.Context, x *xorm.Engine) error {
|
||||
// updateUserQuestionCount update user question count
|
||||
func updateUserQuestionCount(ctx context.Context, x *xorm.Engine) error {
|
||||
questionList := make([]QuestionV13, 0)
|
||||
err := x.Context(ctx).In("status", []int{entity.QuestionStatusAvailable, entity.QuestionStatusClosed}).Find(&questionList, &QuestionV13{})
|
||||
err := x.Context(ctx).Where(builder.Lt{"status": entity.QuestionStatusDeleted}).Find(&questionList, &QuestionV13{})
|
||||
if err != nil {
|
||||
return fmt.Errorf("get question failed: %w", err)
|
||||
}
|
||||
|
||||
@@ -276,7 +276,7 @@ func (qr *questionRepo) GetQuestionList(ctx context.Context, question *entity.Qu
|
||||
|
||||
func (qr *questionRepo) GetQuestionCount(ctx context.Context) (count int64, err error) {
|
||||
session := qr.data.DB.Context(ctx)
|
||||
session.In("status", []int{entity.QuestionStatusAvailable, entity.QuestionStatusClosed})
|
||||
session.Where(builder.Lt{"status": entity.QuestionStatusDeleted})
|
||||
count, err = session.Count(&entity.Question{Show: entity.QuestionShow})
|
||||
if err != nil {
|
||||
return 0, errors.InternalServer(reason.DatabaseError).WithError(err).WithStack()
|
||||
@@ -286,7 +286,7 @@ func (qr *questionRepo) GetQuestionCount(ctx context.Context) (count int64, err
|
||||
|
||||
func (qr *questionRepo) GetUserQuestionCount(ctx context.Context, userID string) (count int64, err error) {
|
||||
session := qr.data.DB.Context(ctx)
|
||||
session.In("status", []int{entity.QuestionStatusAvailable, entity.QuestionStatusClosed})
|
||||
session.Where(builder.Lt{"status": entity.QuestionStatusDeleted})
|
||||
count, err = session.Count(&entity.Question{UserID: userID})
|
||||
if err != nil {
|
||||
return count, errors.InternalServer(reason.DatabaseError).WithError(err).WithStack()
|
||||
|
||||
Reference in New Issue
Block a user