feat: ability to create a task #14

Merged
matous-volf merged 12 commits from feat/task-create into main 2024-08-22 21:40:47 +00:00
2 changed files with 31 additions and 0 deletions
Showing only changes of commit f989f0b9bf - Show all commits

View File

@ -1,2 +1,3 @@
mod database_connection;
pub(crate) mod projects;
pub(crate) mod tasks;

30
src/server/tasks.rs Normal file
View File

@ -0,0 +1,30 @@
coderabbitai[bot] commented 2024-08-22 20:20:54 +00:00 (Migrated from github.com)
Review

Avoid using unwrap() for database operations.

Using unwrap() can lead to panics if the database operation fails. Consider handling the error with map_err or expect with a meaningful message.

Replace unwrap() with proper error handling to prevent potential panics.

**Avoid using `unwrap()` for database operations.** Using `unwrap()` can lead to panics if the database operation fails. Consider handling the error with `map_err` or `expect` with a meaningful message. Replace `unwrap()` with proper error handling to prevent potential panics. <!-- This is an auto-generated comment by CodeRabbit -->
coderabbitai[bot] commented 2024-08-22 20:20:54 +00:00 (Migrated from github.com)
Review

Avoid using unwrap() for database operations.

Using unwrap() can lead to panics if the database operation fails. Consider handling the error with map_err or expect with a meaningful message.

Replace unwrap() with proper error handling to prevent potential panics.

**Avoid using `unwrap()` for database operations.** Using `unwrap()` can lead to panics if the database operation fails. Consider handling the error with `map_err` or `expect` with a meaningful message. Replace `unwrap()` with proper error handling to prevent potential panics. <!-- This is an auto-generated comment by CodeRabbit -->
use crate::errors::error::Error;
coderabbitai[bot] commented 2024-08-22 20:20:54 +00:00 (Migrated from github.com)
Review

Avoid using unwrap() for database operations.

Using unwrap() can lead to panics if the database operation fails. Consider handling the error with map_err or expect with a meaningful message.

Replace unwrap() with proper error handling to prevent potential panics.

**Avoid using `unwrap()` for database operations.** Using `unwrap()` can lead to panics if the database operation fails. Consider handling the error with `map_err` or `expect` with a meaningful message. Replace `unwrap()` with proper error handling to prevent potential panics. <!-- This is an auto-generated comment by CodeRabbit -->
use crate::errors::error_vec::ErrorVec;
coderabbitai[bot] commented 2024-08-22 20:20:54 +00:00 (Migrated from github.com)
Review

Avoid using unwrap() for database operations.

Using unwrap() can lead to panics if the database operation fails. Consider handling the error with map_err or expect with a meaningful message.

Replace unwrap() with proper error handling to prevent potential panics.

**Avoid using `unwrap()` for database operations.** Using `unwrap()` can lead to panics if the database operation fails. Consider handling the error with `map_err` or `expect` with a meaningful message. Replace `unwrap()` with proper error handling to prevent potential panics. <!-- This is an auto-generated comment by CodeRabbit -->
use crate::models::task::{NewTask, Task};
coderabbitai[bot] commented 2024-08-22 20:20:54 +00:00 (Migrated from github.com)
Review

Avoid using unwrap() for database operations.

Using unwrap() can lead to panics if the database operation fails. Consider handling the error with map_err or expect with a meaningful message.

Replace unwrap() with proper error handling to prevent potential panics.

**Avoid using `unwrap()` for database operations.** Using `unwrap()` can lead to panics if the database operation fails. Consider handling the error with `map_err` or `expect` with a meaningful message. Replace `unwrap()` with proper error handling to prevent potential panics. <!-- This is an auto-generated comment by CodeRabbit -->
use crate::server::database_connection::establish_database_connection;
coderabbitai[bot] commented 2024-08-22 20:20:54 +00:00 (Migrated from github.com)
Review

Avoid using unwrap() for database operations.

Using unwrap() can lead to panics if the database operation fails. Consider handling the error with map_err or expect with a meaningful message.

Replace unwrap() with proper error handling to prevent potential panics.

**Avoid using `unwrap()` for database operations.** Using `unwrap()` can lead to panics if the database operation fails. Consider handling the error with `map_err` or `expect` with a meaningful message. Replace `unwrap()` with proper error handling to prevent potential panics. <!-- This is an auto-generated comment by CodeRabbit -->
use diesel::{RunQueryDsl, SelectableHelper};
coderabbitai[bot] commented 2024-08-22 20:20:54 +00:00 (Migrated from github.com)
Review

Avoid using unwrap() for database operations.

Using unwrap() can lead to panics if the database operation fails. Consider handling the error with map_err or expect with a meaningful message.

Replace unwrap() with proper error handling to prevent potential panics.

**Avoid using `unwrap()` for database operations.** Using `unwrap()` can lead to panics if the database operation fails. Consider handling the error with `map_err` or `expect` with a meaningful message. Replace `unwrap()` with proper error handling to prevent potential panics. <!-- This is an auto-generated comment by CodeRabbit -->
use dioxus::prelude::*;
coderabbitai[bot] commented 2024-08-22 20:20:54 +00:00 (Migrated from github.com)
Review

Avoid using unwrap() for database operations.

Using unwrap() can lead to panics if the database operation fails. Consider handling the error with map_err or expect with a meaningful message.

Replace unwrap() with proper error handling to prevent potential panics.

**Avoid using `unwrap()` for database operations.** Using `unwrap()` can lead to panics if the database operation fails. Consider handling the error with `map_err` or `expect` with a meaningful message. Replace `unwrap()` with proper error handling to prevent potential panics. <!-- This is an auto-generated comment by CodeRabbit -->
use validator::Validate;
coderabbitai[bot] commented 2024-08-22 20:20:54 +00:00 (Migrated from github.com)
Review

Avoid using unwrap() for database operations.

Using unwrap() can lead to panics if the database operation fails. Consider handling the error with map_err or expect with a meaningful message.

Replace unwrap() with proper error handling to prevent potential panics.

**Avoid using `unwrap()` for database operations.** Using `unwrap()` can lead to panics if the database operation fails. Consider handling the error with `map_err` or `expect` with a meaningful message. Replace `unwrap()` with proper error handling to prevent potential panics. <!-- This is an auto-generated comment by CodeRabbit -->
use crate::errors::task_create_error::TaskCreateError;
coderabbitai[bot] commented 2024-08-22 20:20:54 +00:00 (Migrated from github.com)
Review

Avoid using unwrap() for database operations.

Using unwrap() can lead to panics if the database operation fails. Consider handling the error with map_err or expect with a meaningful message.

Replace unwrap() with proper error handling to prevent potential panics.

**Avoid using `unwrap()` for database operations.** Using `unwrap()` can lead to panics if the database operation fails. Consider handling the error with `map_err` or `expect` with a meaningful message. Replace `unwrap()` with proper error handling to prevent potential panics. <!-- This is an auto-generated comment by CodeRabbit -->
coderabbitai[bot] commented 2024-08-22 20:20:54 +00:00 (Migrated from github.com)
Review

Avoid using unwrap() for database operations.

Using unwrap() can lead to panics if the database operation fails. Consider handling the error with map_err or expect with a meaningful message.

Replace unwrap() with proper error handling to prevent potential panics.

**Avoid using `unwrap()` for database operations.** Using `unwrap()` can lead to panics if the database operation fails. Consider handling the error with `map_err` or `expect` with a meaningful message. Replace `unwrap()` with proper error handling to prevent potential panics. <!-- This is an auto-generated comment by CodeRabbit -->
#[server]
coderabbitai[bot] commented 2024-08-22 20:20:54 +00:00 (Migrated from github.com)
Review

Avoid using unwrap() for database operations.

Using unwrap() can lead to panics if the database operation fails. Consider handling the error with map_err or expect with a meaningful message.

Replace unwrap() with proper error handling to prevent potential panics.

**Avoid using `unwrap()` for database operations.** Using `unwrap()` can lead to panics if the database operation fails. Consider handling the error with `map_err` or `expect` with a meaningful message. Replace `unwrap()` with proper error handling to prevent potential panics. <!-- This is an auto-generated comment by CodeRabbit -->
pub(crate) async fn create_task(new_task: NewTask)
coderabbitai[bot] commented 2024-08-22 20:20:54 +00:00 (Migrated from github.com)
Review

Avoid using unwrap() for database operations.

Using unwrap() can lead to panics if the database operation fails. Consider handling the error with map_err or expect with a meaningful message.

Replace unwrap() with proper error handling to prevent potential panics.

**Avoid using `unwrap()` for database operations.** Using `unwrap()` can lead to panics if the database operation fails. Consider handling the error with `map_err` or `expect` with a meaningful message. Replace `unwrap()` with proper error handling to prevent potential panics. <!-- This is an auto-generated comment by CodeRabbit -->
-> Result<Task, ServerFnError<ErrorVec<TaskCreateError>>> {
coderabbitai[bot] commented 2024-08-22 20:20:54 +00:00 (Migrated from github.com)
Review

Avoid using unwrap() for database operations.

Using unwrap() can lead to panics if the database operation fails. Consider handling the error with map_err or expect with a meaningful message.

Replace unwrap() with proper error handling to prevent potential panics.

**Avoid using `unwrap()` for database operations.** Using `unwrap()` can lead to panics if the database operation fails. Consider handling the error with `map_err` or `expect` with a meaningful message. Replace `unwrap()` with proper error handling to prevent potential panics. <!-- This is an auto-generated comment by CodeRabbit -->
use crate::schema::tasks;
coderabbitai[bot] commented 2024-08-22 20:20:54 +00:00 (Migrated from github.com)
Review

Avoid using unwrap() for database operations.

Using unwrap() can lead to panics if the database operation fails. Consider handling the error with map_err or expect with a meaningful message.

Replace unwrap() with proper error handling to prevent potential panics.

**Avoid using `unwrap()` for database operations.** Using `unwrap()` can lead to panics if the database operation fails. Consider handling the error with `map_err` or `expect` with a meaningful message. Replace `unwrap()` with proper error handling to prevent potential panics. <!-- This is an auto-generated comment by CodeRabbit -->
coderabbitai[bot] commented 2024-08-22 20:20:54 +00:00 (Migrated from github.com)
Review

Avoid using unwrap() for database operations.

Using unwrap() can lead to panics if the database operation fails. Consider handling the error with map_err or expect with a meaningful message.

Replace unwrap() with proper error handling to prevent potential panics.

**Avoid using `unwrap()` for database operations.** Using `unwrap()` can lead to panics if the database operation fails. Consider handling the error with `map_err` or `expect` with a meaningful message. Replace `unwrap()` with proper error handling to prevent potential panics. <!-- This is an auto-generated comment by CodeRabbit -->
new_task.validate()
coderabbitai[bot] commented 2024-08-22 20:20:54 +00:00 (Migrated from github.com)
Review

Avoid using unwrap() for database operations.

Using unwrap() can lead to panics if the database operation fails. Consider handling the error with map_err or expect with a meaningful message.

Replace unwrap() with proper error handling to prevent potential panics.

**Avoid using `unwrap()` for database operations.** Using `unwrap()` can lead to panics if the database operation fails. Consider handling the error with `map_err` or `expect` with a meaningful message. Replace `unwrap()` with proper error handling to prevent potential panics. <!-- This is an auto-generated comment by CodeRabbit -->
.map_err::<ErrorVec<TaskCreateError>, _>(|errors| errors.into())?;
coderabbitai[bot] commented 2024-08-22 20:20:54 +00:00 (Migrated from github.com)
Review

Avoid using unwrap() for database operations.

Using unwrap() can lead to panics if the database operation fails. Consider handling the error with map_err or expect with a meaningful message.

Replace unwrap() with proper error handling to prevent potential panics.

**Avoid using `unwrap()` for database operations.** Using `unwrap()` can lead to panics if the database operation fails. Consider handling the error with `map_err` or `expect` with a meaningful message. Replace `unwrap()` with proper error handling to prevent potential panics. <!-- This is an auto-generated comment by CodeRabbit -->
coderabbitai[bot] commented 2024-08-22 20:20:54 +00:00 (Migrated from github.com)
Review

Avoid using unwrap() for database operations.

Using unwrap() can lead to panics if the database operation fails. Consider handling the error with map_err or expect with a meaningful message.

Replace unwrap() with proper error handling to prevent potential panics.

**Avoid using `unwrap()` for database operations.** Using `unwrap()` can lead to panics if the database operation fails. Consider handling the error with `map_err` or `expect` with a meaningful message. Replace `unwrap()` with proper error handling to prevent potential panics. <!-- This is an auto-generated comment by CodeRabbit -->
let mut connection = establish_database_connection()
coderabbitai[bot] commented 2024-08-22 20:20:54 +00:00 (Migrated from github.com)
Review

Avoid using unwrap() for database operations.

Using unwrap() can lead to panics if the database operation fails. Consider handling the error with map_err or expect with a meaningful message.

Replace unwrap() with proper error handling to prevent potential panics.

**Avoid using `unwrap()` for database operations.** Using `unwrap()` can lead to panics if the database operation fails. Consider handling the error with `map_err` or `expect` with a meaningful message. Replace `unwrap()` with proper error handling to prevent potential panics. <!-- This is an auto-generated comment by CodeRabbit -->
.map_err::<ErrorVec<TaskCreateError>, _>(
coderabbitai[bot] commented 2024-08-22 20:20:54 +00:00 (Migrated from github.com)
Review

Avoid using unwrap() for database operations.

Using unwrap() can lead to panics if the database operation fails. Consider handling the error with map_err or expect with a meaningful message.

Replace unwrap() with proper error handling to prevent potential panics.

**Avoid using `unwrap()` for database operations.** Using `unwrap()` can lead to panics if the database operation fails. Consider handling the error with `map_err` or `expect` with a meaningful message. Replace `unwrap()` with proper error handling to prevent potential panics. <!-- This is an auto-generated comment by CodeRabbit -->
|_| vec![TaskCreateError::Error(Error::ServerInternal)].into()
coderabbitai[bot] commented 2024-08-22 20:20:54 +00:00 (Migrated from github.com)
Review

Avoid using unwrap() for database operations.

Using unwrap() can lead to panics if the database operation fails. Consider handling the error with map_err or expect with a meaningful message.

Replace unwrap() with proper error handling to prevent potential panics.

**Avoid using `unwrap()` for database operations.** Using `unwrap()` can lead to panics if the database operation fails. Consider handling the error with `map_err` or `expect` with a meaningful message. Replace `unwrap()` with proper error handling to prevent potential panics. <!-- This is an auto-generated comment by CodeRabbit -->
)?;
coderabbitai[bot] commented 2024-08-22 20:20:54 +00:00 (Migrated from github.com)
Review

Avoid using unwrap() for database operations.

Using unwrap() can lead to panics if the database operation fails. Consider handling the error with map_err or expect with a meaningful message.

Replace unwrap() with proper error handling to prevent potential panics.

**Avoid using `unwrap()` for database operations.** Using `unwrap()` can lead to panics if the database operation fails. Consider handling the error with `map_err` or `expect` with a meaningful message. Replace `unwrap()` with proper error handling to prevent potential panics. <!-- This is an auto-generated comment by CodeRabbit -->
coderabbitai[bot] commented 2024-08-22 21:22:03 +00:00 (Migrated from github.com)
Review

Consider adding logging for database connection errors.

While the error handling for database connection is appropriate, consider logging the error for better traceability.

.map_err::<ErrorVec<TaskCreateError>, _>(
    |e| {
        log::error!("Database connection error: {:?}", e);
        vec![TaskCreateError::Error(Error::ServerInternal)].into()
    }
)?;
**Consider adding logging for database connection errors.** While the error handling for database connection is appropriate, consider logging the error for better traceability. ```rust .map_err::<ErrorVec<TaskCreateError>, _>( |e| { log::error!("Database connection error: {:?}", e); vec![TaskCreateError::Error(Error::ServerInternal)].into() } )?; ``` <!-- This is an auto-generated comment by CodeRabbit -->
coderabbitai[bot] commented 2024-08-22 20:20:54 +00:00 (Migrated from github.com)
Review

Avoid using unwrap() for database operations.

Using unwrap() can lead to panics if the database operation fails. Consider handling the error with map_err or expect with a meaningful message.

Replace unwrap() with proper error handling to prevent potential panics.

**Avoid using `unwrap()` for database operations.** Using `unwrap()` can lead to panics if the database operation fails. Consider handling the error with `map_err` or `expect` with a meaningful message. Replace `unwrap()` with proper error handling to prevent potential panics. <!-- This is an auto-generated comment by CodeRabbit -->
let new_task = diesel::insert_into(tasks::table)
coderabbitai[bot] commented 2024-08-22 20:20:54 +00:00 (Migrated from github.com)
Review

Avoid using unwrap() for database operations.

Using unwrap() can lead to panics if the database operation fails. Consider handling the error with map_err or expect with a meaningful message.

Replace unwrap() with proper error handling to prevent potential panics.

**Avoid using `unwrap()` for database operations.** Using `unwrap()` can lead to panics if the database operation fails. Consider handling the error with `map_err` or `expect` with a meaningful message. Replace `unwrap()` with proper error handling to prevent potential panics. <!-- This is an auto-generated comment by CodeRabbit -->
.values(&new_task)
coderabbitai[bot] commented 2024-08-22 20:20:54 +00:00 (Migrated from github.com)
Review

Avoid using unwrap() for database operations.

Using unwrap() can lead to panics if the database operation fails. Consider handling the error with map_err or expect with a meaningful message.

Replace unwrap() with proper error handling to prevent potential panics.

**Avoid using `unwrap()` for database operations.** Using `unwrap()` can lead to panics if the database operation fails. Consider handling the error with `map_err` or `expect` with a meaningful message. Replace `unwrap()` with proper error handling to prevent potential panics. <!-- This is an auto-generated comment by CodeRabbit -->
.returning(Task::as_returning())
coderabbitai[bot] commented 2024-08-22 20:20:54 +00:00 (Migrated from github.com)
Review

Avoid using unwrap() for database operations.

Using unwrap() can lead to panics if the database operation fails. Consider handling the error with map_err or expect with a meaningful message.

Replace unwrap() with proper error handling to prevent potential panics.

**Avoid using `unwrap()` for database operations.** Using `unwrap()` can lead to panics if the database operation fails. Consider handling the error with `map_err` or `expect` with a meaningful message. Replace `unwrap()` with proper error handling to prevent potential panics. <!-- This is an auto-generated comment by CodeRabbit -->
.get_result(&mut connection)
coderabbitai[bot] commented 2024-08-22 20:20:54 +00:00 (Migrated from github.com)
Review

Avoid using unwrap() for database operations.

Using unwrap() can lead to panics if the database operation fails. Consider handling the error with map_err or expect with a meaningful message.

Replace unwrap() with proper error handling to prevent potential panics.

**Avoid using `unwrap()` for database operations.** Using `unwrap()` can lead to panics if the database operation fails. Consider handling the error with `map_err` or `expect` with a meaningful message. Replace `unwrap()` with proper error handling to prevent potential panics. <!-- This is an auto-generated comment by CodeRabbit -->
.unwrap();
coderabbitai[bot] commented 2024-08-22 20:20:54 +00:00 (Migrated from github.com)
Review

Avoid using unwrap() for database operations.

Using unwrap() can lead to panics if the database operation fails. Consider handling the error with map_err or expect with a meaningful message.

Replace unwrap() with proper error handling to prevent potential panics.

**Avoid using `unwrap()` for database operations.** Using `unwrap()` can lead to panics if the database operation fails. Consider handling the error with `map_err` or `expect` with a meaningful message. Replace `unwrap()` with proper error handling to prevent potential panics. <!-- This is an auto-generated comment by CodeRabbit -->
coderabbitai[bot] commented 2024-08-22 20:20:54 +00:00 (Migrated from github.com)
Review

Avoid using unwrap() for database operations.

Using unwrap() can lead to panics if the database operation fails. Consider handling the error with map_err or expect with a meaningful message.

Replace unwrap() with proper error handling to prevent potential panics.

**Avoid using `unwrap()` for database operations.** Using `unwrap()` can lead to panics if the database operation fails. Consider handling the error with `map_err` or `expect` with a meaningful message. Replace `unwrap()` with proper error handling to prevent potential panics. <!-- This is an auto-generated comment by CodeRabbit -->
Ok(new_task)
coderabbitai[bot] commented 2024-08-22 20:20:54 +00:00 (Migrated from github.com)
Review

Avoid using unwrap() for database operations.

Using unwrap() can lead to panics if the database operation fails. Consider handling the error with map_err or expect with a meaningful message.

Replace unwrap() with proper error handling to prevent potential panics.

**Avoid using `unwrap()` for database operations.** Using `unwrap()` can lead to panics if the database operation fails. Consider handling the error with `map_err` or `expect` with a meaningful message. Replace `unwrap()` with proper error handling to prevent potential panics. <!-- This is an auto-generated comment by CodeRabbit -->
}
coderabbitai[bot] commented 2024-08-22 20:20:54 +00:00 (Migrated from github.com)
Review

Avoid using unwrap() for database operations.

Using unwrap() can lead to panics if the database operation fails. Consider handling the error with map_err or expect with a meaningful message.

Replace unwrap() with proper error handling to prevent potential panics.

**Avoid using `unwrap()` for database operations.** Using `unwrap()` can lead to panics if the database operation fails. Consider handling the error with `map_err` or `expect` with a meaningful message. Replace `unwrap()` with proper error handling to prevent potential panics. <!-- This is an auto-generated comment by CodeRabbit -->