MCPcopy Index your code
hub / github.com/apache/answer / RemoveAnswer

Method RemoveAnswer

internal/service/question_common/question.go:574–599  ·  view source on GitHub ↗

RemoveAnswer delete answer

(ctx context.Context, id string)

Source from the content-addressed store, hash-verified

572
573// RemoveAnswer delete answer
574func (qs *QuestionCommon) RemoveAnswer(ctx context.Context, id string) (err error) {
575 answerinfo, has, err := qs.answerRepo.GetByID(ctx, id)
576 if err != nil {
577 return err
578 }
579 if !has {
580 return nil
581 }
582
583 // user add question count
584
585 err = qs.UpdateAnswerCount(ctx, answerinfo.QuestionID)
586 if err != nil {
587 log.Error("UpdateAnswerCount error", err.Error())
588 }
589 userAnswerCount, err := qs.answerRepo.GetCountByUserID(ctx, answerinfo.UserID)
590 if err != nil {
591 log.Error("GetCountByUserID error", err.Error())
592 }
593 err = qs.userCommon.UpdateAnswerCount(ctx, answerinfo.UserID, int(userAnswerCount))
594 if err != nil {
595 log.Error("user UpdateAnswerCount error", err.Error())
596 }
597
598 return qs.answerRepo.RemoveAnswer(ctx, id)
599}
600
601func (qs *QuestionCommon) SitemapCron(ctx context.Context) {
602 questionNum, err := qs.questionRepo.GetQuestionCount(ctx)

Callers

nothing calls this directly

Calls 5

UpdateAnswerCountMethod · 0.95
GetByIDMethod · 0.65
GetCountByUserIDMethod · 0.65
UpdateAnswerCountMethod · 0.65
RemoveAnswerMethod · 0.65

Tested by

no test coverage detected