sync data that already exist in Answer to meilisearch
(ctx context.Context)
| 32 | |
| 33 | // sync data that already exist in Answer to meilisearch |
| 34 | func (s *Search) sync(ctx context.Context) { |
| 35 | log.Infof("start to sync question data to meilisearch") |
| 36 | if s.syncing { |
| 37 | log.Warnf("syncing is running, skip") |
| 38 | return |
| 39 | } |
| 40 | |
| 41 | syncFns := []func(ctx context.Context, page, pageSize int) (answerList []*plugin.SearchContent, err error){ |
| 42 | s.syncer.GetQuestionsPage, |
| 43 | s.syncer.GetAnswersPage, |
| 44 | } |
| 45 | s.lock.Lock() |
| 46 | defer s.lock.Unlock() |
| 47 | if s.syncing { |
| 48 | log.Warnf("syncing is running, skip") |
| 49 | return |
| 50 | } |
| 51 | |
| 52 | s.syncing = true |
| 53 | for _, fn := range syncFns { |
| 54 | s.syncQuestionAndAnswerData(ctx, fn) |
| 55 | } |
| 56 | s.syncing = false |
| 57 | } |
| 58 | |
| 59 | func (s *Search) syncQuestionAndAnswerData(ctx context.Context, |
| 60 | syncFunc func(ctx context.Context, page, pageSize int) (answerList []*plugin.SearchContent, err error)) { |
no test coverage detected