You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@answer.apache.org by "sy-records (via GitHub)" <gi...@apache.org> on 2023/11/27 09:18:47 UTC

[PR] fix: permalink error on some pages [incubator-answer]

sy-records opened a new pull request, #660:
URL: https://github.com/apache/incubator-answer/pull/660

   close #656


-- 
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] fix: permalink error on some pages [incubator-answer]

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


##########
internal/service/question_common/question.go:
##########
@@ -591,8 +591,13 @@ func (qs *QuestionCommon) ShowListFormat(ctx context.Context, data *entity.Quest
 }
 
 func (qs *QuestionCommon) ShowFormat(ctx context.Context, data *entity.Question) *schema.QuestionInfo {
+	var ID = data.ID
+	if handler.GetEnableShortID(ctx) {
+		ID = uid.EnShortID(data.ID)
+	}
+
 	info := schema.QuestionInfo{}
-	info.ID = data.ID
+	info.ID = ID

Review Comment:
   Wouldn't that be better?
   
   ```go
   	info := schema.QuestionInfo{}
   	info.ID = data.ID
   	if handler.GetEnableShortID(ctx) {
   		info.ID = uid.EnShortID(data.ID)
   	}
   ```



-- 
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] fix: permalink error on some pages [incubator-answer]

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


##########
ui/src/pages/Questions/Ask/index.tsx:
##########
@@ -288,7 +288,7 @@ const Ask = () => {
         modifyQuestion(ep)
           .then(async (res) => {
             await editCaptcha.close();
-            navigate(pathFactory.questionLanding(qid, params.url_title), {
+            navigate(pathFactory.questionLanding(qid, res?.url_title), {

Review Comment:
   It's ok!



-- 
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] fix: permalink error on some pages [incubator-answer]

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


##########
internal/schema/question_schema.go:
##########
@@ -205,6 +205,7 @@ func (req *QuestionUpdate) Check() (errFields []*validator.FormErrorField, err e
 type QuestionBaseInfo struct {
 	ID              string `json:"id" `
 	Title           string `json:"title" xorm:"title"`                       // title
+	UrlTitle        string `json:"url_title" xorm:"url_title"`               // title
 	ViewCount       int    `json:"view_count" xorm:"view_count"`             // view count
 	AnswerCount     int    `json:"answer_count" xorm:"answer_count"`         // answer count
 	CollectionCount int    `json:"collection_count" xorm:"collection_count"` // collection count

Review Comment:
   > Remove all xorm tags?
   
   Yes.



-- 
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] fix: permalink error on some pages [incubator-answer]

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


##########
internal/schema/question_schema.go:
##########
@@ -205,6 +205,7 @@ func (req *QuestionUpdate) Check() (errFields []*validator.FormErrorField, err e
 type QuestionBaseInfo struct {
 	ID              string `json:"id" `
 	Title           string `json:"title" xorm:"title"`                       // title
+	UrlTitle        string `json:"url_title" xorm:"url_title"`               // title
 	ViewCount       int    `json:"view_count" xorm:"view_count"`             // view count
 	AnswerCount     int    `json:"answer_count" xorm:"answer_count"`         // answer count
 	CollectionCount int    `json:"collection_count" xorm:"collection_count"` // collection count

Review Comment:
   > Remove all xorm tags?
   
   Yes. In this struct.



-- 
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] fix: permalink error on some pages [incubator-answer]

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


##########
internal/repo/search_common/search_repo.go:
##########
@@ -483,10 +485,19 @@ func (sr *searchRepo) parseResult(ctx context.Context, res []map[string][]byte)
 		questionIDs = append(questionIDs, string(r["question_id"]))
 		userIDs = append(userIDs, string(r["user_id"]))
 		tp, _ := time.ParseInLocation("2006-01-02 15:04:05", string(r["created_at"]), time.Local)
+
+		ID := string(r["id"])
+		QuestionID := string(r["question_id"])

Review Comment:
   Using `id` and `questionID` for variable name would be better.



##########
ui/src/pages/Questions/Ask/index.tsx:
##########
@@ -288,7 +288,7 @@ const Ask = () => {
         modifyQuestion(ep)
           .then(async (res) => {
             await editCaptcha.close();
-            navigate(pathFactory.questionLanding(qid, params.url_title), {
+            navigate(pathFactory.questionLanding(qid, res?.url_title), {

Review Comment:
   @shuashuai Help to review it.



##########
internal/schema/question_schema.go:
##########
@@ -205,6 +205,7 @@ func (req *QuestionUpdate) Check() (errFields []*validator.FormErrorField, err e
 type QuestionBaseInfo struct {
 	ID              string `json:"id" `
 	Title           string `json:"title" xorm:"title"`                       // title
+	UrlTitle        string `json:"url_title" xorm:"url_title"`               // title
 	ViewCount       int    `json:"view_count" xorm:"view_count"`             // view count
 	AnswerCount     int    `json:"answer_count" xorm:"answer_count"`         // answer count
 	CollectionCount int    `json:"collection_count" xorm:"collection_count"` // collection count

Review Comment:
   The `xorm tag` here must have been misused by someone else, please help me remove it. And remove the final comments, which are redundant. Thanks a lot.



##########
internal/service/question_common/question.go:
##########
@@ -591,8 +591,13 @@ func (qs *QuestionCommon) ShowListFormat(ctx context.Context, data *entity.Quest
 }
 
 func (qs *QuestionCommon) ShowFormat(ctx context.Context, data *entity.Question) *schema.QuestionInfo {
+	ID := data.ID

Review Comment:
   Using `id` for variable name would be better.



-- 
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] fix: permalink error on some pages [incubator-answer]

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


-- 
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] fix: permalink error on some pages [incubator-answer]

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


##########
internal/schema/question_schema.go:
##########
@@ -205,6 +205,7 @@ func (req *QuestionUpdate) Check() (errFields []*validator.FormErrorField, err e
 type QuestionBaseInfo struct {
 	ID              string `json:"id" `
 	Title           string `json:"title" xorm:"title"`                       // title
+	UrlTitle        string `json:"url_title" xorm:"url_title"`               // title
 	ViewCount       int    `json:"view_count" xorm:"view_count"`             // view count
 	AnswerCount     int    `json:"answer_count" xorm:"answer_count"`         // answer count
 	CollectionCount int    `json:"collection_count" xorm:"collection_count"` // collection count

Review Comment:
   Remove all xorm tags?



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