MCPcopy
hub / github.com/apache/answer / SitemapCron

Method SitemapCron

internal/service/question_common/question.go:601–623  ·  view source on GitHub ↗
(ctx context.Context)

Source from the content-addressed store, hash-verified

599}
600
601func (qs *QuestionCommon) SitemapCron(ctx context.Context) {
602 questionNum, err := qs.questionRepo.GetQuestionCount(ctx)
603 if err != nil {
604 log.Error(err)
605 return
606 }
607 if questionNum <= constant.SitemapMaxSize {
608 _, err = qs.questionRepo.SitemapQuestions(ctx, 1, int(questionNum))
609 if err != nil {
610 log.Errorf("get site map question error: %v", err)
611 }
612 return
613 }
614
615 totalPages := int(math.Ceil(float64(questionNum) / float64(constant.SitemapMaxSize)))
616 for i := 1; i <= totalPages; i++ {
617 _, err = qs.questionRepo.SitemapQuestions(ctx, i, constant.SitemapMaxSize)
618 if err != nil {
619 log.Errorf("get site map question error: %v", err)
620 return
621 }
622 }
623}
624
625func (qs *QuestionCommon) SetCache(ctx context.Context, cachekey string, info any) error {
626 infoStr, err := json.Marshal(info)

Callers 1

RunMethod · 0.45

Calls 2

GetQuestionCountMethod · 0.65
SitemapQuestionsMethod · 0.65

Tested by

no test coverage detected