LinkinStars commented on code in PR #918:
URL: https://github.com/apache/incubator-answer/pull/918#discussion_r1577455494


##########
internal/migrations/init.go:
##########
@@ -255,3 +260,143 @@ func (m *Mentor) initSiteInfoWrite() {
                Status:  1,
        })
 }
+
+func (m *Mentor) initDefaultContent() {
+       uniqueIDRepo := unique.NewUniqueIDRepo(&data.Data{DB: m.engine})
+       now := time.Now()
+
+       tag_id, err := uniqueIDRepo.GenUniqueIDStr(m.ctx, 
entity.Tag{}.TableName())
+       if err != nil {
+               m.err = err
+               return
+       }
+
+       q1_id, err := uniqueIDRepo.GenUniqueIDStr(m.ctx, 
entity.Question{}.TableName())
+       if err != nil {
+               m.err = err
+               return
+       }
+
+       a1_id, err := uniqueIDRepo.GenUniqueIDStr(m.ctx, 
entity.Answer{}.TableName())
+       if err != nil {
+               m.err = err
+               return
+       }
+
+       q2_id, err := uniqueIDRepo.GenUniqueIDStr(m.ctx, 
entity.Question{}.TableName())
+       if err != nil {
+               m.err = err
+               return
+       }
+
+       a2_id, err := uniqueIDRepo.GenUniqueIDStr(m.ctx, 
entity.Answer{}.TableName())
+       if err != nil {
+               m.err = err
+               return
+       }
+
+       tag := entity.Tag{
+               ID:            tag_id,
+               SlugName:      "support",
+               DisplayName:   "support",
+               OriginalText:  "For general support questions.",
+               ParsedText:    "<p>For general support questions.</p>",
+               UserID:        "1",
+               QuestionCount: 1,
+               Status:        entity.TagStatusAvailable,
+       }
+
+       q1 := &entity.Question{
+               ID:               q1_id,
+               CreatedAt:        now,
+               UserID:           "1",
+               Title:            "What is a tag?",
+               OriginalText:     "When asking a question, we need to choose 
tags. What are tags and why should I use them?",
+               ParsedText:       "<p>When asking a question, we need to choose 
tags. What are tags and why should I use them?</p>",
+               Pin:              entity.QuestionPin,
+               Show:             entity.QuestionShow,
+               Status:           entity.QuestionStatusAvailable,
+               AnswerCount:      1,
+               AcceptedAnswerID: a1_id,
+       }
+
+       a1 := &entity.Answer{
+               ID:           a1_id,
+               CreatedAt:    now,
+               QuestionID:   q1_id,
+               UserID:       "1",
+               OriginalText: "Tags help to organize content and make searching 
easier. It helps your question get more attention from people interested in 
that tag. Tags also send notifications. If you are interested in some topic, 
follow that tag to get updates.",
+               ParsedText:   "<p>Tags help to organize content and make 
searching easier. It helps your question get more attention from people 
interested in that tag. Tags also send notifications. If you are interested in 
some topic, follow that tag to get updates.</p>",
+               Status:       entity.AnswerStatusAvailable,
+               Accepted:     schema.AnswerAcceptedEnable,
+       }
+
+       q2 := &entity.Question{
+               ID:               q2_id,
+               CreatedAt:        now,
+               UserID:           "1",
+               Title:            "What is reputation and how do I earn them?",
+               OriginalText:     "I see that each user has reputation points, 
What is it and how do I earn them?",
+               ParsedText:       "<p>I see that each user has reputation 
points, What is it and how do I earn them?</p>",
+               Pin:              entity.QuestionPin,
+               Show:             entity.QuestionShow,
+               Status:           entity.QuestionStatusAvailable,
+               AnswerCount:      1,
+               AcceptedAnswerID: a2_id,
+       }
+
+       a2 := &entity.Answer{
+               ID:           a2_id,
+               CreatedAt:    now,
+               QuestionID:   q2_id,
+               UserID:       "1",
+               OriginalText: "Your reputation points show how much the 
community values your knowledge. You earn points when someone find your 
question or answer helpful. You also get points when the person who asked the 
question thinks you did a good job and accepts your answer.",
+               ParsedText:   "<p>Your reputation points show how much the 
community values your knowledge. You earn points when someone find your 
question or answer helpful. You also get points when the person who asked the 
question thinks you did a good job and accepts your answer.</p>",
+               Status:       entity.AnswerStatusAvailable,
+               Accepted:     schema.AnswerAcceptedEnable,
+       }
+
+       _, m.err = m.engine.Context(m.ctx).Insert(tag)
+       if m.err != nil {
+               return
+       }
+
+       _, m.err = m.engine.Context(m.ctx).Insert(q1)
+       if m.err != nil {
+               return
+       }
+
+       _, m.err = m.engine.Context(m.ctx).Insert(a1)
+       if m.err != nil {
+               return
+       }
+
+       _, m.err = m.engine.Context(m.ctx).Insert(entity.TagRel{
+               CreatedAt: now,

Review Comment:
   Just like below, no need to set the time here.



##########
internal/migrations/init.go:
##########
@@ -255,3 +260,143 @@ func (m *Mentor) initSiteInfoWrite() {
                Status:  1,
        })
 }
+
+func (m *Mentor) initDefaultContent() {
+       uniqueIDRepo := unique.NewUniqueIDRepo(&data.Data{DB: m.engine})
+       now := time.Now()
+
+       tag_id, err := uniqueIDRepo.GenUniqueIDStr(m.ctx, 
entity.Tag{}.TableName())
+       if err != nil {
+               m.err = err
+               return
+       }
+
+       q1_id, err := uniqueIDRepo.GenUniqueIDStr(m.ctx, 
entity.Question{}.TableName())
+       if err != nil {
+               m.err = err
+               return
+       }
+
+       a1_id, err := uniqueIDRepo.GenUniqueIDStr(m.ctx, 
entity.Answer{}.TableName())
+       if err != nil {
+               m.err = err
+               return
+       }
+
+       q2_id, err := uniqueIDRepo.GenUniqueIDStr(m.ctx, 
entity.Question{}.TableName())
+       if err != nil {
+               m.err = err
+               return
+       }
+
+       a2_id, err := uniqueIDRepo.GenUniqueIDStr(m.ctx, 
entity.Answer{}.TableName())
+       if err != nil {
+               m.err = err
+               return
+       }
+
+       tag := entity.Tag{
+               ID:            tag_id,
+               SlugName:      "support",
+               DisplayName:   "support",
+               OriginalText:  "For general support questions.",
+               ParsedText:    "<p>For general support questions.</p>",
+               UserID:        "1",
+               QuestionCount: 1,
+               Status:        entity.TagStatusAvailable,
+       }
+
+       q1 := &entity.Question{
+               ID:               q1_id,
+               CreatedAt:        now,
+               UserID:           "1",
+               Title:            "What is a tag?",
+               OriginalText:     "When asking a question, we need to choose 
tags. What are tags and why should I use them?",
+               ParsedText:       "<p>When asking a question, we need to choose 
tags. What are tags and why should I use them?</p>",
+               Pin:              entity.QuestionPin,

Review Comment:
   The questions don't need to be pinned to the top.



##########
internal/migrations/init.go:
##########
@@ -255,3 +260,143 @@ func (m *Mentor) initSiteInfoWrite() {
                Status:  1,
        })
 }
+
+func (m *Mentor) initDefaultContent() {
+       uniqueIDRepo := unique.NewUniqueIDRepo(&data.Data{DB: m.engine})
+       now := time.Now()
+
+       tag_id, err := uniqueIDRepo.GenUniqueIDStr(m.ctx, 
entity.Tag{}.TableName())
+       if err != nil {
+               m.err = err
+               return
+       }
+
+       q1_id, err := uniqueIDRepo.GenUniqueIDStr(m.ctx, 
entity.Question{}.TableName())
+       if err != nil {
+               m.err = err
+               return
+       }
+
+       a1_id, err := uniqueIDRepo.GenUniqueIDStr(m.ctx, 
entity.Answer{}.TableName())
+       if err != nil {
+               m.err = err
+               return
+       }
+
+       q2_id, err := uniqueIDRepo.GenUniqueIDStr(m.ctx, 
entity.Question{}.TableName())
+       if err != nil {
+               m.err = err
+               return
+       }
+
+       a2_id, err := uniqueIDRepo.GenUniqueIDStr(m.ctx, 
entity.Answer{}.TableName())
+       if err != nil {
+               m.err = err
+               return
+       }
+
+       tag := entity.Tag{
+               ID:            tag_id,
+               SlugName:      "support",
+               DisplayName:   "support",
+               OriginalText:  "For general support questions.",
+               ParsedText:    "<p>For general support questions.</p>",
+               UserID:        "1",
+               QuestionCount: 1,
+               Status:        entity.TagStatusAvailable,
+       }
+
+       q1 := &entity.Question{
+               ID:               q1_id,
+               CreatedAt:        now,
+               UserID:           "1",
+               Title:            "What is a tag?",
+               OriginalText:     "When asking a question, we need to choose 
tags. What are tags and why should I use them?",
+               ParsedText:       "<p>When asking a question, we need to choose 
tags. What are tags and why should I use them?</p>",
+               Pin:              entity.QuestionPin,
+               Show:             entity.QuestionShow,
+               Status:           entity.QuestionStatusAvailable,
+               AnswerCount:      1,
+               AcceptedAnswerID: a1_id,

Review Comment:
   The answer corresponding to the question does not need to be accepted.



##########
internal/migrations/init.go:
##########
@@ -255,3 +260,143 @@ func (m *Mentor) initSiteInfoWrite() {
                Status:  1,
        })
 }
+
+func (m *Mentor) initDefaultContent() {
+       uniqueIDRepo := unique.NewUniqueIDRepo(&data.Data{DB: m.engine})
+       now := time.Now()
+
+       tag_id, err := uniqueIDRepo.GenUniqueIDStr(m.ctx, 
entity.Tag{}.TableName())

Review Comment:
   <img width="701" alt="image" 
src="https://github.com/apache/incubator-answer/assets/19712692/26d8c19f-363f-4071-a204-d764d1305a93";>
   
   In golang, we use camel case instead of snake case.



##########
internal/migrations/init.go:
##########
@@ -255,3 +260,143 @@ func (m *Mentor) initSiteInfoWrite() {
                Status:  1,
        })
 }
+
+func (m *Mentor) initDefaultContent() {
+       uniqueIDRepo := unique.NewUniqueIDRepo(&data.Data{DB: m.engine})
+       now := time.Now()
+
+       tag_id, err := uniqueIDRepo.GenUniqueIDStr(m.ctx, 
entity.Tag{}.TableName())
+       if err != nil {
+               m.err = err
+               return
+       }
+
+       q1_id, err := uniqueIDRepo.GenUniqueIDStr(m.ctx, 
entity.Question{}.TableName())
+       if err != nil {
+               m.err = err
+               return
+       }
+
+       a1_id, err := uniqueIDRepo.GenUniqueIDStr(m.ctx, 
entity.Answer{}.TableName())
+       if err != nil {
+               m.err = err
+               return
+       }
+
+       q2_id, err := uniqueIDRepo.GenUniqueIDStr(m.ctx, 
entity.Question{}.TableName())
+       if err != nil {
+               m.err = err
+               return
+       }
+
+       a2_id, err := uniqueIDRepo.GenUniqueIDStr(m.ctx, 
entity.Answer{}.TableName())
+       if err != nil {
+               m.err = err
+               return
+       }
+
+       tag := entity.Tag{
+               ID:            tag_id,
+               SlugName:      "support",
+               DisplayName:   "support",
+               OriginalText:  "For general support questions.",
+               ParsedText:    "<p>For general support questions.</p>",
+               UserID:        "1",
+               QuestionCount: 1,
+               Status:        entity.TagStatusAvailable,
+       }
+
+       q1 := &entity.Question{
+               ID:               q1_id,
+               CreatedAt:        now,
+               UserID:           "1",
+               Title:            "What is a tag?",
+               OriginalText:     "When asking a question, we need to choose 
tags. What are tags and why should I use them?",
+               ParsedText:       "<p>When asking a question, we need to choose 
tags. What are tags and why should I use them?</p>",
+               Pin:              entity.QuestionPin,
+               Show:             entity.QuestionShow,
+               Status:           entity.QuestionStatusAvailable,
+               AnswerCount:      1,
+               AcceptedAnswerID: a1_id,
+       }
+
+       a1 := &entity.Answer{
+               ID:           a1_id,
+               CreatedAt:    now,
+               QuestionID:   q1_id,
+               UserID:       "1",
+               OriginalText: "Tags help to organize content and make searching 
easier. It helps your question get more attention from people interested in 
that tag. Tags also send notifications. If you are interested in some topic, 
follow that tag to get updates.",
+               ParsedText:   "<p>Tags help to organize content and make 
searching easier. It helps your question get more attention from people 
interested in that tag. Tags also send notifications. If you are interested in 
some topic, follow that tag to get updates.</p>",
+               Status:       entity.AnswerStatusAvailable,
+               Accepted:     schema.AnswerAcceptedEnable,
+       }
+
+       q2 := &entity.Question{
+               ID:               q2_id,
+               CreatedAt:        now,
+               UserID:           "1",
+               Title:            "What is reputation and how do I earn them?",
+               OriginalText:     "I see that each user has reputation points, 
What is it and how do I earn them?",
+               ParsedText:       "<p>I see that each user has reputation 
points, What is it and how do I earn them?</p>",
+               Pin:              entity.QuestionPin,
+               Show:             entity.QuestionShow,
+               Status:           entity.QuestionStatusAvailable,
+               AnswerCount:      1,
+               AcceptedAnswerID: a2_id,

Review Comment:
   The answer corresponding to the question does not need to be accepted.



##########
internal/migrations/init.go:
##########
@@ -255,3 +260,143 @@ func (m *Mentor) initSiteInfoWrite() {
                Status:  1,
        })
 }
+
+func (m *Mentor) initDefaultContent() {
+       uniqueIDRepo := unique.NewUniqueIDRepo(&data.Data{DB: m.engine})
+       now := time.Now()
+
+       tag_id, err := uniqueIDRepo.GenUniqueIDStr(m.ctx, 
entity.Tag{}.TableName())
+       if err != nil {
+               m.err = err
+               return
+       }
+
+       q1_id, err := uniqueIDRepo.GenUniqueIDStr(m.ctx, 
entity.Question{}.TableName())
+       if err != nil {
+               m.err = err
+               return
+       }
+
+       a1_id, err := uniqueIDRepo.GenUniqueIDStr(m.ctx, 
entity.Answer{}.TableName())
+       if err != nil {
+               m.err = err
+               return
+       }
+
+       q2_id, err := uniqueIDRepo.GenUniqueIDStr(m.ctx, 
entity.Question{}.TableName())
+       if err != nil {
+               m.err = err
+               return
+       }
+
+       a2_id, err := uniqueIDRepo.GenUniqueIDStr(m.ctx, 
entity.Answer{}.TableName())
+       if err != nil {
+               m.err = err
+               return
+       }
+
+       tag := entity.Tag{
+               ID:            tag_id,
+               SlugName:      "support",
+               DisplayName:   "support",
+               OriginalText:  "For general support questions.",
+               ParsedText:    "<p>For general support questions.</p>",
+               UserID:        "1",
+               QuestionCount: 1,
+               Status:        entity.TagStatusAvailable,
+       }
+
+       q1 := &entity.Question{
+               ID:               q1_id,
+               CreatedAt:        now,
+               UserID:           "1",
+               Title:            "What is a tag?",
+               OriginalText:     "When asking a question, we need to choose 
tags. What are tags and why should I use them?",
+               ParsedText:       "<p>When asking a question, we need to choose 
tags. What are tags and why should I use them?</p>",
+               Pin:              entity.QuestionPin,
+               Show:             entity.QuestionShow,
+               Status:           entity.QuestionStatusAvailable,
+               AnswerCount:      1,
+               AcceptedAnswerID: a1_id,
+       }
+
+       a1 := &entity.Answer{
+               ID:           a1_id,
+               CreatedAt:    now,
+               QuestionID:   q1_id,
+               UserID:       "1",
+               OriginalText: "Tags help to organize content and make searching 
easier. It helps your question get more attention from people interested in 
that tag. Tags also send notifications. If you are interested in some topic, 
follow that tag to get updates.",
+               ParsedText:   "<p>Tags help to organize content and make 
searching easier. It helps your question get more attention from people 
interested in that tag. Tags also send notifications. If you are interested in 
some topic, follow that tag to get updates.</p>",
+               Status:       entity.AnswerStatusAvailable,
+               Accepted:     schema.AnswerAcceptedEnable,
+       }
+
+       q2 := &entity.Question{
+               ID:               q2_id,
+               CreatedAt:        now,
+               UserID:           "1",
+               Title:            "What is reputation and how do I earn them?",
+               OriginalText:     "I see that each user has reputation points, 
What is it and how do I earn them?",
+               ParsedText:       "<p>I see that each user has reputation 
points, What is it and how do I earn them?</p>",
+               Pin:              entity.QuestionPin,

Review Comment:
   The questions don't need to be pinned to the top.



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

Reply via email to