You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@answer.apache.org by "ferrischi201 (via GitHub)" <gi...@apache.org> on 2024/08/06 15:16:58 UTC

[PR] feat(recommend): add tag-based recommendations in question page [incubator-answer]

ferrischi201 opened a new pull request, #1070:
URL: https://github.com/apache/incubator-answer/pull/1070

   Propose adding recommended questions to resolve issue #1003 .


-- 
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(recommend): add tag-based recommendations in question page [incubator-answer]

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


-- 
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(recommend): add tag-based recommendations in question page [incubator-answer]

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

   @LinkinStars Thanks for your review! Conditions are added in SQLs now to filter out deleted or unlisted questions. The function has been optimized to handle cases where no tag IDs are provided, no followed questions exist, or both are missing. Feel free to run any tests against 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(recommend): add tag-based recommendations in question page [incubator-answer]

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

   @LinkinStars Thanks for your review! Conditions are added in SQLs now to filter out deleted or unlisted questions. The function has been optimized to handle cases where no tag IDs are provided, no followed questions exist, or both are missing. Feel free to run any tests against 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(recommend): add tag-based recommendations in question page [incubator-answer]

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

   @LinkinStars Thank you for bringing this error. MySQL, PostgreSQL, and SQLite have all been tested and should be working correctly at this time. I've rebased the branch to the latest dev branch for your convenience.


-- 
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(recommend): add tag-based recommendations in question page [incubator-answer]

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

   Sorry for replying so late as we are testing a lot of scenarios. I found some issues.
   
   1. If a question has been deleted then it should not appear in this recommended list.
   ![QQ_1723618224014](https://github.com/user-attachments/assets/c21ce49e-d633-4cc8-9f49-9b910f842b37)
   ![QQ_1723618265174](https://github.com/user-attachments/assets/c07faaa7-c6fd-40a3-9ba2-ea597b0ef489)
   
   
   2. If a question has been unlisted then it should not appear in this recommended list.
   ![QQ_1723618306502](https://github.com/user-attachments/assets/99e30d1f-aa15-4526-82d2-08af5e493a0a)
    
   3. 
   When the user doesn't follow the question, means `followedQuestionIDs` is empty, it may need to make special judgement. In PostgreSQL scenario, it will report an error.
   
   ```
   [SQL] SELECT DISTINCT question.* FROM "question" INNER JOIN "tag_rel" ON question.id = tag_rel.object_id INNER JOIN "tag" ON tag.id = tag_rel.tag_id WHERE (((question.user_id != $1 and question.status = $2) AND (question.id NOT IN (SELECT question_id FROM answer WHERE user_id = $3)) AND (tag_rel.status = $4) AND 0=1) OR 0=1) ORDER BY CASE WHEN question.id IN ('') THEN 0 ELSE 1 END, question.pin DESC, question.created_at DESC LIMIT 20 [10040000000000237 1 10040000000000237 1] - 1.084875ms
   2024-08-14 14:36:19.305 ERROR   handler/handler.go:53   code: 500, reason: base.database_error, message: , error: pq: invalid input syntax for type bigint: ""
   incubator-answer/internal/repo/question/question_repo.go:426 github.com/apache/incubator-answer/internal/repo/question.(*questionRepo).GetRecommendQuestionPageByTags
   ```
   Of course, when `followedQuestionIDs` is empty, I think `orderBySQL` could be optimised a bit too.
   


-- 
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(recommend): add tag-based recommendations in question page [incubator-answer]

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

   Thank you very much for your contribution. 👍


-- 
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(recommend): add tag-based recommendations in question page [incubator-answer]

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


##########
internal/service/content/question_service.go:
##########
@@ -1348,6 +1356,47 @@ func (qs *QuestionService) GetQuestionPage(ctx context.Context, req *schema.Ques
 	return questions, total, nil
 }
 
+// GetRecommendQuestionPage retrieves recommended question page based on following tags and questions.
+func (qs *QuestionService) GetRecommendQuestionPage(ctx context.Context, req *schema.QuestionPageReq) (
+	questions []*schema.QuestionPageResp, total int64, err error) {
+	followingTagsResp, err := qs.tagService.GetFollowingTags(ctx, req.LoginUserID)

Review Comment:
   When the user is not logged in, that the LoginUserID is empty, empty data can be returned directly. Otherwise, in the scenario of using pg, an error will occur when the user directly accesses the page `/questions?order=recommend`.
   
   ```go
   2024-09-03 10:25:48.627 ERROR   handler/handler.go:53   code: 500, reason: base.database_error, message: , error: pq: invalid input syntax for type bigint: ""
   incubator-answer/internal/repo/activity_common/activity_repo.go:118 github.com/apache/incubator-answer/internal/repo/activity_common.(*ActivityRepo).GetUserActivitysByActivityType
   incubator-answer/internal/service/content/question_service.go:1375 github.com/apache/incubator-answer/internal/service/content.(*QuestionService).GetRecommendQuestionPage
   incubator-answer/internal/controller/question_controller.go:350 github.com/apache/incubator-answer/internal/controller.(*QuestionController).QuestionRecommendPage
   go/pkg/mod/github.com/gin-gonic/gin@v1.9.1/context.go:174 github.com/gin-gonic/gin.(*Context).Next
   incubator-answer/internal/base/middleware/auth.go:88 github.com/apache/incubator-answer/internal/base/server.NewHTTPServer.(*AuthUserMiddleware).EjectUserBySiteInfo.func9
   go/pkg/mod/github.com/gin-gonic/gin@v1.9.1/context.go:174 github.com/gin-gonic/gin.(*Context).Next
   incubator-answer/internal/base/middleware/auth.go:64 github.com/apache/incubator-answer/internal/base/server.NewHTTPServer.(*AuthUserMiddleware).Auth.func8
   go/pkg/mod/github.com/gin-gonic/gin@v1.9.1/context.go:174 github.com/gin-gonic/gin.(*Context).Next
   go/pkg/mod/github.com/anargu/gin-brotli@v0.0.0-20220116052358-12bf532d5267/gin_brotli.go:71 github.com/apache/incubator-answer/internal/base/server.NewHTTPServer.Brotli.func3
   go/pkg/mod/github.com/gin-gonic/gin@v1.9.1/context.go:174 github.com/gin-gonic/gin.(*Context).Next
   go/pkg/mod/github.com/gin-gonic/gin@v1.9.1/gin.go:620 github.com/gin-gonic/gin.(*Engine).handleHTTPRequest
   go/pkg/mod/github.com/gin-gonic/gin@v1.9.1/gin.go:576 github.com/gin-gonic/gin.(*Engine).ServeHTTP
   /usr/local/go/src/net/http/server.go:3137 net/http.serverHandler.ServeHTTP
   /usr/local/go/src/net/http/server.go:2039 net/http.(*conn).serve
   /usr/local/go/src/runtime/asm_arm64.s:1222 runtime.goexit
   
   ```



-- 
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(recommend): add tag-based recommendations in question page [incubator-answer]

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


##########
go.mod:
##########
@@ -17,7 +17,7 @@
 
 module github.com/apache/incubator-answer
 
-go 1.18
+go 1.22.3

Review Comment:
   Sorry about that. Changed back to `go 1.18` in `go.mod` and `go.sum` accordingly.



-- 
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(recommend): add tag-based recommendations in question page [incubator-answer]

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


##########
go.mod:
##########
@@ -17,7 +17,7 @@
 
 module github.com/apache/incubator-answer
 
-go 1.18
+go 1.22.3

Review Comment:
   Do not upgrade the version of golang.



-- 
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(recommend): add tag-based recommendations in question page [incubator-answer]

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

   @ferrischi201  After following the question. In the PostgreSQL scenario, it will report an error.
   
   ```
   SELECT DISTINCT question.* FROM "question" INNER JOIN "tag_rel" ON question.id = tag_rel.object_id INNER JOIN "tag" ON tag.id = tag_rel.tag_id WHERE (((question.user_id != $1) AND (question.id NOT IN (SELECT question_id FROM answer WHERE user_id = $2)) AND (tag_rel.status = $3) AND "tag"."id" IN ($4)) OR question.id IN ($5)) AND (question.show = $6 and question.status = $7) ORDER BY CASE WHEN question.id IN ('10010000000000005') THEN 0 ELSE 1 END, question.pin DESC, question.created_at DESC LIMIT 20 [1 1 1 10030000000000004 10010000000000005 1 1] - 575.916µs
   2024-08-19 15:21:16.852 ERROR   handler/handler.go:53   code: 500, reason: base.database_error, message: , error: pq: for SELECT DISTINCT, ORDER BY expressions must appear in select list
   ```
   
   


-- 
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(recommend): add tag-based recommendations in question page [incubator-answer]

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

   Thanks for pointing this out. It's an unexpected behaviour for guest users and is resolved with a userid check.


-- 
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