add comments for work todo

This commit is contained in:
David Westgate 2024-05-29 16:36:56 -07:00
parent b34ffe8029
commit 6e428b4b97
2 changed files with 38 additions and 6 deletions

View File

@ -102,10 +102,22 @@ pub async fn update_question(
State(store): State<Arc<RwLock<Store>>>, State(store): State<Arc<RwLock<Store>>>,
Json(question): Json<Question>, Json(question): Json<Question>,
) -> Response { ) -> Response {
match store.write().await.update_question(question) { // Step 0: Update the question entry
Ok(question) => question.into_response(), // Step 1: Fetch the question_tags for the given tags
Err(e) => (StatusCode::NOT_FOUND, e).into_response(), // Step 2: Fetch the tags for the given question tags
} // Step 3: new_tags_labels = list of tag labels not already on question
// Step 3a: Fetch existing_new_tag as tags which already by given name exist, but do not yet have a question_tag association
// Step 3b: Create question_tag association for 3a
// Step 3c: Create new tags which do not already exist
// Step 3d: Create question_tag association for 3c
// Step 4: remove_tag_labls = list of tag labs which should no longer have a question_tag association with the question
// Step 4a: Fetch existing_old_tags as tags by given na
// match store.write().await.update_question(question) {
// Ok(question) => question.into_response(),
// Err(e) => (StatusCode::NOT_FOUND, e).into_response(),
// }
todo!()
} }
/// Delete an existing question /// Delete an existing question

View File

@ -166,11 +166,31 @@ impl Store {
_ => None, _ => None,
} }
} }
/// Remove tags from tags table, which have no question tag association
/// Returns true if any tags were removed, false otherwise
pub fn remove_orphan_tags(&mut self){
todo!()
}
/// Creates passed in tag labels in the tags table, only if they do not already exists
/// Returns list of all tags from passed in labels, regardless of if they already existed
pub fn add_tags_if_not_exists(&mut self, tags_labels: Vec<String>){
todo!()
}
///
pub fn sync_question_tags(&mut self, tags: Vec<Tag>){
todo!()
}
pub fn update_question(&mut self, _question: Question) -> Result<Question, String> { pub fn update_question(&mut self, _question: Question) -> Result<Question, String> {
Err("To Do".to_string()) todo!()
} }
pub fn add_answer(&mut self, _id: u8, _answer: Answer) -> Result<Answer, String> { pub fn add_answer(&mut self, _id: u8, _answer: Answer) -> Result<Answer, String> {
Err("To Do".to_string()) todo!()
} }
} }