(ctx context.Context)
| 599 | } |
| 600 | |
| 601 | func (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 | |
| 625 | func (qs *QuestionCommon) SetCache(ctx context.Context, cachekey string, info any) error { |
| 626 | infoStr, err := json.Marshal(info) |
no test coverage detected