From 7aa0858642ccc6bc52faae6111de003afc40b975 Mon Sep 17 00:00:00 2001 From: Pierre HUBERT Date: Thu, 21 Jan 2021 18:23:23 +0100 Subject: [PATCH] Can delete all responses to survey of a user --- src/helpers/account_helper.rs | 3 +++ src/helpers/survey_helper.rs | 7 +++++++ 2 files changed, 10 insertions(+) diff --git a/src/helpers/account_helper.rs b/src/helpers/account_helper.rs index f99c200..8011dee 100644 --- a/src/helpers/account_helper.rs +++ b/src/helpers/account_helper.rs @@ -312,6 +312,9 @@ pub fn delete(user_id: &UserID) -> ResultBoxError { // Delete all user posts posts_helper::delete_all_user(user_id)?; + // Delete all responses of user to surveys + survey_helper::delete_all_user_responses(user_id)?; + // TODO : continue work here Ok(()) diff --git a/src/helpers/survey_helper.rs b/src/helpers/survey_helper.rs index 1c2b8f7..328a3c6 100644 --- a/src/helpers/survey_helper.rs +++ b/src/helpers/survey_helper.rs @@ -143,6 +143,13 @@ pub fn export_all_user_responses(user_id: &UserID) -> ResultBoxError ResultBoxError { + database::DeleteQuery::new(SURVEY_RESPONSE_TABLE) + .cond_user_id("ID_utilisateurs", user_id) + .exec() +} + /// Turn a database entry into a row object fn db_to_survey(row: &database::RowResult) -> ResultBoxError { let survey_id = row.get_u64("ID")?;