You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@answer.apache.org by "foxzero-007 (via GitHub)" <gi...@apache.org> on 2024/03/05 11:25:35 UTC

[PR] feat: filter the same question in similar questions [incubator-answer]

foxzero-007 opened a new pull request, #828:
URL: https://github.com/apache/incubator-answer/pull/828

   I would like to offer a small suggestion regarding the user experience. Currently, the related questions during a search do not seem to exclude the current issue itself. I'm not sure if this may cause some confusion for other users, but I personally prefer to have the current problem excluded from the "related questions" to enhance the browsing experience.
   Before:
   ![image](https://github.com/apache/incubator-answer/assets/58644520/f11baf08-bae4-44e2-96e0-37763a3557b0)
   After:
   ![image](https://github.com/apache/incubator-answer/assets/58644520/e14cdcdf-8adb-4058-bace-1d65408f991f)
   


-- 
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: commits-unsubscribe@answer.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] feat: filter the same question in similar questions [incubator-answer]

Posted by "LinkinStars (via GitHub)" <gi...@apache.org>.
LinkinStars commented on code in PR #828:
URL: https://github.com/apache/incubator-answer/pull/828#discussion_r1513917666


##########
internal/service/question_service.go:
##########
@@ -1235,7 +1235,17 @@ func (qs *QuestionService) SimilarQuestion(ctx context.Context, questionID strin
 		search.Tag = tagNames[0]
 	}
 	search.LoginUserID = loginUserID
-	return qs.GetQuestionPage(ctx, search)
+	similarQuestions, _ , err := qs.GetQuestionPage(ctx, search)
+	if err !=nil {
+		return nil, 0, err
+	}
+	var result []*schema.QuestionPageResp
+  for _, v := range similarQuestions {
+      if v.ID != questionID {
+          result = append(result, v)
+      }
+  }
+	return result, int64(len(result)), nil

Review Comment:
   You might need to use go fmt to adjust your code format. 🤔



-- 
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: commits-unsubscribe@answer.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] feat: filter the same question in similar questions [incubator-answer]

Posted by "foxzero-007 (via GitHub)" <gi...@apache.org>.
foxzero-007 commented on PR #828:
URL: https://github.com/apache/incubator-answer/pull/828#issuecomment-1980253397

   @LinkinStars  Yes, you're right. It seems I made a somewhat silly mistake🤦‍♂️. I have now corrected it and tested it.


-- 
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: commits-unsubscribe@answer.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] feat: filter the same question in similar questions [incubator-answer]

Posted by "foxzero-007 (via GitHub)" <gi...@apache.org>.
foxzero-007 commented on code in PR #828:
URL: https://github.com/apache/incubator-answer/pull/828#discussion_r1513926872


##########
internal/service/question_service.go:
##########
@@ -1235,7 +1235,17 @@ func (qs *QuestionService) SimilarQuestion(ctx context.Context, questionID strin
 		search.Tag = tagNames[0]
 	}
 	search.LoginUserID = loginUserID
-	return qs.GetQuestionPage(ctx, search)
+	similarQuestions, _ , err := qs.GetQuestionPage(ctx, search)
+	if err !=nil {
+		return nil, 0, err
+	}
+	var result []*schema.QuestionPageResp
+  for _, v := range similarQuestions {
+      if v.ID != questionID {
+          result = append(result, v)
+      }
+  }
+	return result, int64(len(result)), nil

Review Comment:
   Sorry, it was my oversight. I have already completed this suggestion.



-- 
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: commits-unsubscribe@answer.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] feat: filter the same question in similar questions [incubator-answer]

Posted by "LinkinStars (via GitHub)" <gi...@apache.org>.
LinkinStars merged PR #828:
URL: https://github.com/apache/incubator-answer/pull/828


-- 
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: commits-unsubscribe@answer.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] feat: filter the same question in similar questions [incubator-answer]

Posted by "LinkinStars (via GitHub)" <gi...@apache.org>.
LinkinStars commented on PR #828:
URL: https://github.com/apache/incubator-answer/pull/828#issuecomment-1980225246

   @foxzero-007 Thank you for your contribution. There are some small issues. When using short ID, the `GetQuestionPage` method returns content that has already been formatted, so v.ID is already a short ID for display, and questionID is a real long ID. This would make the current code redundant. So you might need to convert `v.ID` to a short ID using `uid.DeShortID` method. You can test this by modifying the configuration in the image below and running the code to test again.
   
   <img width="885" alt="image" src="https://github.com/apache/incubator-answer/assets/19712692/6169f298-b184-489c-b712-cbeac12ecd68">
   


-- 
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: commits-unsubscribe@answer.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org