1
0
mirror of https://gitlab.com/comunic/comunicapiv3 synced 2024-11-22 21:39:21 +00:00

Can delete all responses to survey of a user

This commit is contained in:
Pierre HUBERT 2021-01-21 18:23:23 +01:00
parent ffbb81bade
commit 7aa0858642
2 changed files with 10 additions and 0 deletions

View File

@ -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(())

View File

@ -143,6 +143,13 @@ pub fn export_all_user_responses(user_id: &UserID) -> ResultBoxError<Vec<SurveyR
.exec(db_to_survey_response)
}
/// Delete all the responses of a user to surveys
pub fn delete_all_user_responses(user_id: &UserID) -> 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<Survey> {
let survey_id = row.get_u64("ID")?;