LinkinStars commented on code in PR #1275:
URL: https://github.com/apache/answer/pull/1275#discussion_r1984352594
##########
internal/service/question_common/question.go:
##########
@@ -409,8 +409,8 @@ func (qs *QuestionCommon) FormatQuestionsPage(
}
}
- // if order condition is newest or nobody edited or nobody
answered, only show question author
- if orderCond == schema.QuestionOrderCondNewest || (!haveEdited
&& !haveAnswered) {
+ // If the order condition is not active or no one has
edited/answered, display only the question author
+ if orderCond != schema.QuestionOrderCondActive || (!haveEdited
&& !haveAnswered) {
Review Comment:
😄 Aha, maybe I had a little problem with the description. There was nothing
wrong with your original logic and I was trying to change it to something like
the following to make it a little clearer. See if you understand it a little
better.
```go
// The default operation is to ask questions
t.OperationType = schema.QuestionPageRespOperationTypeAsked
t.OperatedAt = questionInfo.CreatedAt.Unix()
t.Operator = &schema.QuestionPageRespOperator{ID: questionInfo.UserID}
// If the order is active, the last operation time is the last edit or
answer time if it exists
if orderCond == schema.QuestionOrderCondActive {
if haveEdited {
t.OperationType = schema.QuestionPageRespOperationTypeModified
t.OperatedAt = questionInfo.UpdatedAt.Unix()
t.Operator = &schema.QuestionPageRespOperator{ID:
questionInfo.LastEditUserID}
}
if haveAnswered {
if t.LastAnsweredAt.Unix() > t.OperatedAt {
t.OperationType =
schema.QuestionPageRespOperationTypeAnswered
t.OperatedAt = t.LastAnsweredAt.Unix()
t.Operator = &schema.QuestionPageRespOperator{ID:
t.LastAnsweredUserID}
}
}
}
```
##########
internal/service/question_common/question.go:
##########
@@ -409,8 +409,8 @@ func (qs *QuestionCommon) FormatQuestionsPage(
}
}
- // if order condition is newest or nobody edited or nobody
answered, only show question author
- if orderCond == schema.QuestionOrderCondNewest || (!haveEdited
&& !haveAnswered) {
+ // If the order condition is not active or no one has
edited/answered, display only the question author
+ if orderCond != schema.QuestionOrderCondActive || (!haveEdited
&& !haveAnswered) {
Review Comment:
> Only the "Active" filter shows the last person who performed the action,
e.g., answered, modified.
https://github.com/apache/answer/issues/1270#issuecomment-2696093377
That means the other conditions always show the operator who asked the
question.
So, the `orderCond == schema.QuestionOrderCondActive` condition is enough.
Remove the `|| (!haveEdited && !haveAnswered)`
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]