From 6e428b4b970b2240a0f32b0a5eef7f183660a7aa Mon Sep 17 00:00:00 2001 From: David Westgate Date: Wed, 29 May 2024 16:36:56 -0700 Subject: [PATCH] add comments for work todo --- src/api.rs | 20 ++++++++++++++++---- src/pg_store.rs | 24 ++++++++++++++++++++++-- 2 files changed, 38 insertions(+), 6 deletions(-) diff --git a/src/api.rs b/src/api.rs index 5ad73bb..fbdb131 100644 --- a/src/api.rs +++ b/src/api.rs @@ -102,10 +102,22 @@ pub async fn update_question( State(store): State>>, Json(question): Json, ) -> Response { - match store.write().await.update_question(question) { - Ok(question) => question.into_response(), - Err(e) => (StatusCode::NOT_FOUND, e).into_response(), - } + // Step 0: Update the question entry + // Step 1: Fetch the question_tags for the given tags + // 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 diff --git a/src/pg_store.rs b/src/pg_store.rs index 556eb58..f786c2e 100644 --- a/src/pg_store.rs +++ b/src/pg_store.rs @@ -166,11 +166,31 @@ impl Store { _ => 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){ + todo!() + } + + /// + pub fn sync_question_tags(&mut self, tags: Vec){ + todo!() + } + + + pub fn update_question(&mut self, _question: Question) -> Result { - Err("To Do".to_string()) + todo!() } pub fn add_answer(&mut self, _id: u8, _answer: Answer) -> Result { - Err("To Do".to_string()) + todo!() } }