(ctx context.Context, data *data.Data, vectorSearch plugin.VectorSearch, action, objectType, objectID string)
| 85 | } |
| 86 | |
| 87 | func handleOnce(ctx context.Context, data *data.Data, vectorSearch plugin.VectorSearch, |
| 88 | action, objectType, objectID string) error { |
| 89 | if action == ActionDelete { |
| 90 | return vectorSearch.DeleteContent(ctx, objectID) |
| 91 | } |
| 92 | if action != ActionUpsert { |
| 93 | return nil |
| 94 | } |
| 95 | |
| 96 | var ( |
| 97 | content *plugin.VectorSearchContent |
| 98 | err error |
| 99 | ) |
| 100 | switch objectType { |
| 101 | case ObjectTypeQuestion: |
| 102 | content, err = vector_search_sync.BuildQuestionContentByID(ctx, data, objectID) |
| 103 | case ObjectTypeAnswer: |
| 104 | content, err = vector_search_sync.BuildAnswerContentByID(ctx, data, objectID) |
| 105 | default: |
| 106 | return nil |
| 107 | } |
| 108 | if err != nil { |
| 109 | return err |
| 110 | } |
| 111 | if content == nil { |
| 112 | return vectorSearch.DeleteContent(ctx, objectID) |
| 113 | } |
| 114 | return vectorSearch.UpdateContent(ctx, content) |
| 115 | } |
no test coverage detected