feat: ability to delete a task #39

Merged
matous-volf merged 4 commits from feat/task-delete into main 2024-09-08 08:07:42 +00:00
Showing only changes of commit 7b98527882 - Show all commits

View File

@ -136,3 +136,19 @@ pub(crate) async fn complete_task(task_id: i32) -> Result<Task, ServerFnError<Er
Ok(updated_task)
}
// TODO: Get rid of this suppression.
coderabbitai[bot] commented 2024-09-08 07:59:56 +00:00 (Migrated from github.com)
Review

Acknowledge the TODO comment regarding code suppression.

The TODO comment about removing code suppression for duplicated code is noted. It's important to prioritize this task to improve code maintainability and reduce technical debt.

Would you like me to help identify areas of code duplication and suggest refactoring opportunities?

**Acknowledge the TODO comment regarding code suppression.** The TODO comment about removing code suppression for duplicated code is noted. It's important to prioritize this task to improve code maintainability and reduce technical debt. Would you like me to help identify areas of code duplication and suggest refactoring opportunities? <!-- This is an auto-generated comment by CodeRabbit -->
//noinspection DuplicatedCode
#[server]
pub(crate) async fn delete_task(task_id: i32)
-> Result<(), ServerFnError<ErrorVec<Error>>> {
use crate::schema::tasks::dsl::*;
let mut connection = establish_database_connection()
.map_err::<ErrorVec<Error>, _>(|_| vec![Error::ServerInternal].into())?;
diesel::delete(tasks.filter(id.eq(task_id))).execute(&mut connection)
.map_err::<ErrorVec<Error>, _>(|error| vec![error.into()].into())?;
Ok(())
}
coderabbitai[bot] commented 2024-09-08 07:59:56 +00:00 (Migrated from github.com)
Review

Approve the implementation of delete_task.

The function delete_task is implemented correctly and uses standard practices for database operations and error handling in Rust. However, consider adding more specific error handling for different types of database errors to improve the robustness of the function.

**Approve the implementation of `delete_task`.** The function `delete_task` is implemented correctly and uses standard practices for database operations and error handling in Rust. However, consider adding more specific error handling for different types of database errors to improve the robustness of the function. <!-- This is an auto-generated comment by CodeRabbit -->