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,6 +119,7 @@ func (s *FileProboCollectorStore) UpdateQuiz(r *client.CreateUpdateQuizRequest,
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if id != quiz.ID { // Update and re-index only if quiz hash is changed
|
||||||
err = s.createOrUpdateMarkdownFile(quiz)
|
err = s.createOrUpdateMarkdownFile(quiz)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
|
@ -128,7 +129,7 @@ func (s *FileProboCollectorStore) UpdateQuiz(r *client.CreateUpdateQuizRequest,
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
|
}
|
||||||
return s.memoryStore.ReadQuizByHash(quiz.Hash)
|
return s.memoryStore.ReadQuizByHash(quiz.Hash)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -187,6 +187,7 @@ func (t *testSuite) TestUpdateQuiz() {
|
||||||
}, quiz.ID)
|
}, quiz.ID)
|
||||||
|
|
||||||
t.Nil(err, fmt.Sprintf("Quiz should be updated without errors: %v", err))
|
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() {
|
if !t.Failed() {
|
||||||
path, err := store.GetPath(updatedQuiz)
|
path, err := store.GetPath(updatedQuiz)
|
||||||
|
|
|
@ -149,7 +149,7 @@ func (s *MemoryProboCollectorStore) createOrUpdateQuiz(r *client.CreateUpdateQui
|
||||||
|
|
||||||
if id != "" {
|
if id != "" {
|
||||||
quiz = s.getQuizFromID(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)
|
return nil, fmt.Errorf("Quiz ID %v doesn't exist in the store!", id)
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
|
|
Loading…
Reference in a new issue