Re-index only if quiz hash as changed
This commit is contained in:
parent
7f4849c575
commit
f21e77c682
3 changed files with 11 additions and 9 deletions
|
@ -119,16 +119,17 @@ func (s *FileProboCollectorStore) UpdateQuiz(r *client.CreateUpdateQuizRequest,
|
|||
return nil, err
|
||||
}
|
||||
|
||||
err = s.createOrUpdateMarkdownFile(quiz)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
if id != quiz.ID { // Update and re-index only if quiz hash is changed
|
||||
err = s.createOrUpdateMarkdownFile(quiz)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
err = s.Reindex()
|
||||
if err != nil {
|
||||
return nil, err
|
||||
err = s.Reindex()
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
}
|
||||
|
||||
return s.memoryStore.ReadQuizByHash(quiz.Hash)
|
||||
}
|
||||
|
||||
|
|
|
@ -187,6 +187,7 @@ func (t *testSuite) TestUpdateQuiz() {
|
|||
}, quiz.ID)
|
||||
|
||||
t.Nil(err, fmt.Sprintf("Quiz should be updated without errors: %v", err))
|
||||
// t.Equal(updatedQuiz.ID, quiz.ID, "Quiz ID should remain the same")
|
||||
|
||||
if !t.Failed() {
|
||||
path, err := store.GetPath(updatedQuiz)
|
||||
|
|
|
@ -149,7 +149,7 @@ func (s *MemoryProboCollectorStore) createOrUpdateQuiz(r *client.CreateUpdateQui
|
|||
|
||||
if id != "" {
|
||||
quiz = s.getQuizFromID(id)
|
||||
if quiz == nil { // Quiz is already present in the store
|
||||
if quiz == nil { // Quiz is not present in the store
|
||||
return nil, fmt.Errorf("Quiz ID %v doesn't exist in the store!", id)
|
||||
}
|
||||
} else {
|
||||
|
|
Loading…
Reference in a new issue