fix comments for update question api

This commit is contained in:
David Westgate 2024-06-01 19:51:56 -07:00
parent afdc564efc
commit 036f4c4779

View File

@ -113,28 +113,28 @@ pub async fn update_question(
match current_tags_option { match current_tags_option {
Some(current_tags) => { Some(current_tags) => {
let incoming_tag_labels = question.tags; let incoming_tag_labels = question.tags;
// Create (ignored if they already exist, new tags for the incoming tags) // 3: Create (ignored if they already exist, new tags for the incoming tags)
let incoming_tags = store let incoming_tags = store
.write() .write()
.await .await
.add_tags(incoming_tag_labels) .add_tags(incoming_tag_labels)
.await .await
.unwrap(); .unwrap();
// Unassociated all current tags with this question // 4: Unassociated all current tags with this question
let _remove_tags = store let _remove_tags = store
.write() .write()
.await .await
.unassociate_tags(updated_question.id, current_tags) .unassociate_tags(updated_question.id, current_tags)
.await .await
.unwrap(); .unwrap();
// Associated all of the incoming tags (now newly created if needed) with the question // 5: Associated all of the incoming tags (now newly created if needed) with the question
let _updated_tags = store let _updated_tags = store
.write() .write()
.await .await
.associate_tags(updated_question.id, &incoming_tags) .associate_tags(updated_question.id, &incoming_tags)
.await .await
.unwrap(); .unwrap();
//Return the updated question with the updated tags //6: Return the updated question with the updated tags
QuestionDTO::new(updated_question, incoming_tags).into_response() QuestionDTO::new(updated_question, incoming_tags).into_response()
} }
None => (StatusCode::OK).into_response(), None => (StatusCode::OK).into_response(),