Skip to content

Commit

Permalink
recorded_fileをまとめて更新する
Browse files Browse the repository at this point in the history
  • Loading branch information
kounoike committed Apr 30, 2023
1 parent 88c7f3a commit 48140fe
Showing 1 changed file with 7 additions and 4 deletions.
11 changes: 7 additions & 4 deletions meili/meilisearch.go
Original file line number Diff line number Diff line change
Expand Up @@ -100,6 +100,7 @@ func (m *MeiliSearchClient) DeleteRecordedFileIndex() error {
func (m *MeiliSearchClient) UpdateRecordedFiles(rows []db.ListRecordedFilesRow) error {
index := m.Index(recordedFileIndexName)

documents := make([]map[string]interface{}, 0, len(rows))
for _, row := range rows {
document := map[string]interface{}{
"id": row.ProgramID,
Expand Down Expand Up @@ -133,10 +134,12 @@ func (m *MeiliSearchClient) UpdateRecordedFiles(rows []db.ListRecordedFilesRow)
document["文字起こし"] = string(bytes)
}
}
_, err := index.UpdateDocuments([]map[string]interface{}{document})
if err != nil {
m.logger.Warn("failed to update documents", zap.Error(err), zap.Any("document", document))
}
documents = append(documents, document)
}

_, err := index.UpdateDocuments(documents)
if err != nil {
m.logger.Warn("failed to update documents", zap.Error(err), zap.Any("documents", documents))
}

return nil
Expand Down

0 comments on commit 48140fe

Please sign in to comment.