style: fix the rustfmt linted files
	
		
			
	
		
	
	
		
	
		
			Some checks failed
		
		
	
	
		
			
				
	
				actionlint check / actionlint check (pull_request) Successful in 5s
				
			
		
			
				
	
				checkov check / checkov check (pull_request) Successful in 52s
				
			
		
			
				
	
				conventional commit messages check / conventional commit messages check (pull_request) Successful in 4s
				
			
		
			
				
	
				conventional pull request title check / conventional pull request title check (pull_request) Successful in 2s
				
			
		
			
				
	
				dotenv-linter check / dotenv-linter check (pull_request) Successful in 5s
				
			
		
			
				
	
				GitLeaks check / GitLeaks check (pull_request) Successful in 6s
				
			
		
			
				
	
				hadolint check / hadolint check (pull_request) Successful in 7s
				
			
		
			
				
	
				htmlhint check / htmlhint check (pull_request) Successful in 9s
				
			
		
			
				
	
				markdownlint check / markdownlint check (pull_request) Successful in 9s
				
			
		
			
				
	
				Prettier check / Prettier check (pull_request) Successful in 10s
				
			
		
			
				
	
				Rust check / Rust check (pull_request) Failing after 6m20s
				
			
		
			
				
	
				ShellCheck check / ShellCheck check (pull_request) Successful in 12s
				
			
		
			
				
	
				Stylelint check / Stylelint check (pull_request) Successful in 11s
				
			
		
			
				
	
				yamllint check / yamllint check (pull_request) Successful in 13s
				
			
		
		
	
	
				
					
				
			
		
			Some checks failed
		
		
	
	actionlint check / actionlint check (pull_request) Successful in 5s
				
			checkov check / checkov check (pull_request) Successful in 52s
				
			conventional commit messages check / conventional commit messages check (pull_request) Successful in 4s
				
			conventional pull request title check / conventional pull request title check (pull_request) Successful in 2s
				
			dotenv-linter check / dotenv-linter check (pull_request) Successful in 5s
				
			GitLeaks check / GitLeaks check (pull_request) Successful in 6s
				
			hadolint check / hadolint check (pull_request) Successful in 7s
				
			htmlhint check / htmlhint check (pull_request) Successful in 9s
				
			markdownlint check / markdownlint check (pull_request) Successful in 9s
				
			Prettier check / Prettier check (pull_request) Successful in 10s
				
			Rust check / Rust check (pull_request) Failing after 6m20s
				
			ShellCheck check / ShellCheck check (pull_request) Successful in 12s
				
			Stylelint check / Stylelint check (pull_request) Successful in 11s
				
			yamllint check / yamllint check (pull_request) Successful in 13s
				
			This commit is contained in:
		| @@ -1,8 +1,8 @@ | ||||
| use std::env; | ||||
| use dioxus::prelude::ServerFnError; | ||||
| use unic_langid_impl::LanguageIdentifier; | ||||
| use dioxus::prelude::*; | ||||
| use dotenvy::dotenv; | ||||
| use std::env; | ||||
| use unic_langid_impl::LanguageIdentifier; | ||||
|  | ||||
| #[server] | ||||
| pub(crate) async fn get_language_identifier() -> Result<LanguageIdentifier, ServerFnError> { | ||||
|   | ||||
| @@ -1,5 +1,5 @@ | ||||
| pub(crate) mod database_connection; | ||||
| pub(crate) mod projects; | ||||
| pub(crate) mod tasks; | ||||
| pub(crate) mod subtasks; | ||||
| pub(crate) mod internationalization; | ||||
| pub(crate) mod projects; | ||||
| pub(crate) mod subtasks; | ||||
| pub(crate) mod tasks; | ||||
|   | ||||
| @@ -8,21 +8,23 @@ use dioxus::prelude::*; | ||||
| use validator::Validate; | ||||
|  | ||||
| #[server] | ||||
| pub(crate) async fn create_project(new_project: NewProject) | ||||
|                                    -> Result<Project, ServerFnError<ErrorVec<ProjectError>>> { | ||||
| pub(crate) async fn create_project( | ||||
|     new_project: NewProject, | ||||
| ) -> Result<Project, ServerFnError<ErrorVec<ProjectError>>> { | ||||
|     use crate::schema::projects; | ||||
|  | ||||
|     // TODO: replace with model sanitization (https://github.com/matous-volf/todo-baggins/issues/13) | ||||
|     let mut new_project = new_project; | ||||
|     new_project.title = new_project.title.trim().to_owned(); | ||||
|  | ||||
|     new_project.validate() | ||||
|     new_project | ||||
|         .validate() | ||||
|         .map_err::<ErrorVec<ProjectError>, _>(|errors| errors.into())?; | ||||
|  | ||||
|     let mut connection = establish_database_connection() | ||||
|         .map_err::<ErrorVec<ProjectError>, _>( | ||||
|             |_| vec![ProjectError::Error(Error::ServerInternal)].into() | ||||
|         )?; | ||||
|     let mut connection = | ||||
|         establish_database_connection().map_err::<ErrorVec<ProjectError>, _>(|_| { | ||||
|             vec![ProjectError::Error(Error::ServerInternal)].into() | ||||
|         })?; | ||||
|  | ||||
|     let new_project = diesel::insert_into(projects::table) | ||||
|         .values(&new_project) | ||||
| @@ -34,41 +36,39 @@ pub(crate) async fn create_project(new_project: NewProject) | ||||
| } | ||||
|  | ||||
| #[server] | ||||
| pub(crate) async fn get_projects() | ||||
|     -> Result<Vec<Project>, ServerFnError<ErrorVec<Error>>> { | ||||
| pub(crate) async fn get_projects() -> Result<Vec<Project>, ServerFnError<ErrorVec<Error>>> { | ||||
|     use crate::schema::projects::dsl::*; | ||||
|  | ||||
|     let mut connection = establish_database_connection() | ||||
|         .map_err::<ErrorVec<Error>, _>( | ||||
|             |_| vec![Error::ServerInternal].into() | ||||
|         )?; | ||||
|         .map_err::<ErrorVec<Error>, _>(|_| vec![Error::ServerInternal].into())?; | ||||
|  | ||||
|     let results = projects | ||||
|         .select(Project::as_select()) | ||||
|         .load::<Project>(&mut connection) | ||||
|         .map_err::<ErrorVec<Error>, _>( | ||||
|             |_| vec![Error::ServerInternal].into() | ||||
|         )?; | ||||
|         .map_err::<ErrorVec<Error>, _>(|_| vec![Error::ServerInternal].into())?; | ||||
|  | ||||
|     Ok(results) | ||||
| } | ||||
|  | ||||
| #[server] | ||||
| pub(crate) async fn edit_project(project_id: i32, new_project: NewProject) | ||||
|                                  -> Result<Project, ServerFnError<ErrorVec<ProjectError>>> { | ||||
| pub(crate) async fn edit_project( | ||||
|     project_id: i32, | ||||
|     new_project: NewProject, | ||||
| ) -> Result<Project, ServerFnError<ErrorVec<ProjectError>>> { | ||||
|     use crate::schema::projects::dsl::*; | ||||
|  | ||||
|     // TODO: replace with model sanitization (https://github.com/matous-volf/todo-baggins/issues/13) | ||||
|     let mut new_project = new_project; | ||||
|     new_project.title = new_project.title.trim().to_owned(); | ||||
|  | ||||
|     new_project.validate() | ||||
|     new_project | ||||
|         .validate() | ||||
|         .map_err::<ErrorVec<ProjectError>, _>(|errors| errors.into())?; | ||||
|  | ||||
|     let mut connection = establish_database_connection() | ||||
|         .map_err::<ErrorVec<ProjectError>, _>( | ||||
|             |_| vec![ProjectError::Error(Error::ServerInternal)].into() | ||||
|         )?; | ||||
|     let mut connection = | ||||
|         establish_database_connection().map_err::<ErrorVec<ProjectError>, _>(|_| { | ||||
|             vec![ProjectError::Error(Error::ServerInternal)].into() | ||||
|         })?; | ||||
|  | ||||
|     let updated_project = diesel::update(projects) | ||||
|         .filter(id.eq(project_id)) | ||||
| @@ -83,15 +83,14 @@ pub(crate) async fn edit_project(project_id: i32, new_project: NewProject) | ||||
| // TODO: Get rid of this suppression. | ||||
| //noinspection DuplicatedCode | ||||
| #[server] | ||||
| pub(crate) async fn delete_project(project_id: i32) | ||||
|                                    -> Result<(), ServerFnError<ErrorVec<Error>>> { | ||||
| pub(crate) async fn delete_project(project_id: i32) -> Result<(), ServerFnError<ErrorVec<Error>>> { | ||||
|     use crate::schema::projects::dsl::*; | ||||
|  | ||||
|     let mut connection = establish_database_connection() | ||||
|         .map_err::<ErrorVec<Error>, _>(|_| vec![Error::ServerInternal].into())?; | ||||
|  | ||||
|      | ||||
|     diesel::delete(projects.filter(id.eq(project_id))).execute(&mut connection) | ||||
|     diesel::delete(projects.filter(id.eq(project_id))) | ||||
|         .execute(&mut connection) | ||||
|         .map_err::<ErrorVec<Error>, _>(|error| vec![error.into()].into())?; | ||||
|  | ||||
|     Ok(()) | ||||
|   | ||||
| @@ -3,43 +3,47 @@ use crate::errors::error_vec::ErrorVec; | ||||
| use crate::errors::subtask_error::SubtaskError; | ||||
| use crate::models::subtask::{NewSubtask, Subtask}; | ||||
| use crate::server::database_connection::establish_database_connection; | ||||
| use crate::server::tasks::trigger_task_updated_at; | ||||
| use diesel::{ExpressionMethods, QueryDsl, RunQueryDsl, SelectableHelper}; | ||||
| use dioxus::prelude::*; | ||||
| use validator::Validate; | ||||
| use crate::server::tasks::trigger_task_updated_at; | ||||
|  | ||||
| #[server] | ||||
| pub(crate) async fn create_subtask(new_subtask: NewSubtask) | ||||
|                                    -> Result<Subtask, ServerFnError<ErrorVec<SubtaskError>>> { | ||||
| pub(crate) async fn create_subtask( | ||||
|     new_subtask: NewSubtask, | ||||
| ) -> Result<Subtask, ServerFnError<ErrorVec<SubtaskError>>> { | ||||
|     use crate::schema::subtasks; | ||||
|  | ||||
|     // TODO: replace with model sanitization (https://github.com/matous-volf/todo-baggins/issues/13) | ||||
|     let mut new_subtask = new_subtask; | ||||
|     new_subtask.title = new_subtask.title.trim().to_owned(); | ||||
|  | ||||
|     new_subtask.validate() | ||||
|     new_subtask | ||||
|         .validate() | ||||
|         .map_err::<ErrorVec<SubtaskError>, _>(|errors| errors.into())?; | ||||
|  | ||||
|     let mut connection = establish_database_connection() | ||||
|         .map_err::<ErrorVec<SubtaskError>, _>( | ||||
|             |_| vec![SubtaskError::Error(Error::ServerInternal)].into() | ||||
|         )?; | ||||
|     let mut connection = | ||||
|         establish_database_connection().map_err::<ErrorVec<SubtaskError>, _>(|_| { | ||||
|             vec![SubtaskError::Error(Error::ServerInternal)].into() | ||||
|         })?; | ||||
|  | ||||
|     let created_subtask = diesel::insert_into(subtasks::table) | ||||
|         .values(&new_subtask) | ||||
|         .returning(Subtask::as_returning()) | ||||
|         .get_result(&mut connection) | ||||
|         .map_err::<ErrorVec<SubtaskError>, _>(|error| vec![error.into()].into())?; | ||||
|      | ||||
|     trigger_task_updated_at(new_subtask.task_id).await | ||||
|  | ||||
|     trigger_task_updated_at(new_subtask.task_id) | ||||
|         .await | ||||
|         .map_err::<ErrorVec<SubtaskError>, _>(|error_vec| error_vec.into())?; | ||||
|  | ||||
|     Ok(created_subtask) | ||||
| } | ||||
|  | ||||
| #[server] | ||||
| pub(crate) async fn get_subtasks_of_task(filtered_task_id: i32) | ||||
|                                          -> Result<Vec<Subtask>, ServerFnError<ErrorVec<Error>>> { | ||||
| pub(crate) async fn get_subtasks_of_task( | ||||
|     filtered_task_id: i32, | ||||
| ) -> Result<Vec<Subtask>, ServerFnError<ErrorVec<Error>>> { | ||||
|     use crate::schema::subtasks::dsl::*; | ||||
|  | ||||
|     let mut connection = establish_database_connection() | ||||
| @@ -55,43 +59,46 @@ pub(crate) async fn get_subtasks_of_task(filtered_task_id: i32) | ||||
| } | ||||
|  | ||||
| #[server] | ||||
| pub(crate) async fn edit_subtask(subtask_id: i32, new_subtask: NewSubtask) | ||||
|                                  -> Result<Subtask, ServerFnError<ErrorVec<SubtaskError>>> { | ||||
| pub(crate) async fn edit_subtask( | ||||
|     subtask_id: i32, | ||||
|     new_subtask: NewSubtask, | ||||
| ) -> Result<Subtask, ServerFnError<ErrorVec<SubtaskError>>> { | ||||
|     use crate::schema::subtasks::dsl::*; | ||||
|  | ||||
|     // TODO: replace with model sanitization (https://github.com/matous-volf/todo-baggins/issues/13) | ||||
|     let mut new_subtask = new_subtask; | ||||
|     new_subtask.title = new_subtask.title.trim().to_owned(); | ||||
|  | ||||
|     new_subtask.validate() | ||||
|     new_subtask | ||||
|         .validate() | ||||
|         .map_err::<ErrorVec<SubtaskError>, _>(|errors| errors.into())?; | ||||
|  | ||||
|     let mut connection = establish_database_connection() | ||||
|         .map_err::<ErrorVec<SubtaskError>, _>( | ||||
|             |_| vec![SubtaskError::Error(Error::ServerInternal)].into() | ||||
|         )?; | ||||
|     let mut connection = | ||||
|         establish_database_connection().map_err::<ErrorVec<SubtaskError>, _>(|_| { | ||||
|             vec![SubtaskError::Error(Error::ServerInternal)].into() | ||||
|         })?; | ||||
|  | ||||
|     let updated_task = diesel::update(subtasks) | ||||
|         .filter(id.eq(subtask_id)) | ||||
|         .set(( | ||||
|             title.eq(new_subtask.title), | ||||
|             is_completed.eq(new_subtask.is_completed) | ||||
|             is_completed.eq(new_subtask.is_completed), | ||||
|         )) | ||||
|         .returning(Subtask::as_returning()) | ||||
|         .get_result(&mut connection) | ||||
|         .map_err::<ErrorVec<SubtaskError>, _>(|error| vec![error.into()].into())?; | ||||
|  | ||||
|     trigger_task_updated_at(new_subtask.task_id).await | ||||
|     trigger_task_updated_at(new_subtask.task_id) | ||||
|         .await | ||||
|         .map_err::<ErrorVec<SubtaskError>, _>(|error_vec| error_vec.into())?; | ||||
|      | ||||
|  | ||||
|     Ok(updated_task) | ||||
| } | ||||
|  | ||||
| #[server] | ||||
| pub(crate) async fn restore_subtasks_of_task(filtered_task_id: i32) -> Result< | ||||
|     Vec<Subtask>, | ||||
|     ServerFnError<ErrorVec<Error>> | ||||
| > { | ||||
| pub(crate) async fn restore_subtasks_of_task( | ||||
|     filtered_task_id: i32, | ||||
| ) -> Result<Vec<Subtask>, ServerFnError<ErrorVec<Error>>> { | ||||
|     use crate::schema::subtasks::dsl::*; | ||||
|  | ||||
|     let mut connection = establish_database_connection() | ||||
| @@ -110,8 +117,7 @@ pub(crate) async fn restore_subtasks_of_task(filtered_task_id: i32) -> Result< | ||||
| // TODO: Get rid of this suppression. | ||||
| //noinspection DuplicatedCode | ||||
| #[server] | ||||
| pub(crate) async fn delete_subtask(subtask_id: i32) | ||||
|                                    -> Result<(), ServerFnError<ErrorVec<Error>>> { | ||||
| pub(crate) async fn delete_subtask(subtask_id: i32) -> Result<(), ServerFnError<ErrorVec<Error>>> { | ||||
|     use crate::schema::subtasks::dsl::*; | ||||
|  | ||||
|     let mut connection = establish_database_connection() | ||||
|   | ||||
| @@ -1,34 +1,36 @@ | ||||
| use chrono::{Datelike, Days, Local, Months, NaiveDate}; | ||||
| use crate::errors::error::Error; | ||||
| use crate::errors::error_vec::ErrorVec; | ||||
| use crate::models::task::{NewTask, Task, TaskWithSubtasks}; | ||||
| use crate::server::database_connection::establish_database_connection; | ||||
| use diesel::{ExpressionMethods, OptionalExtension, QueryDsl, RunQueryDsl, SelectableHelper}; | ||||
| use dioxus::prelude::*; | ||||
| use diesel::prelude::*; | ||||
| use time::util::days_in_year_month; | ||||
| use validator::Validate; | ||||
| use crate::errors::task_error::TaskError; | ||||
| use crate::models::category::{Category, ReoccurrenceInterval}; | ||||
| use crate::models::subtask::Subtask; | ||||
| use crate::models::task::{NewTask, Task, TaskWithSubtasks}; | ||||
| use crate::server::database_connection::establish_database_connection; | ||||
| use crate::server::subtasks::restore_subtasks_of_task; | ||||
| use chrono::{Datelike, Days, Local, Months, NaiveDate}; | ||||
| use diesel::prelude::*; | ||||
| use diesel::{ExpressionMethods, OptionalExtension, QueryDsl, RunQueryDsl, SelectableHelper}; | ||||
| use dioxus::prelude::*; | ||||
| use time::util::days_in_year_month; | ||||
| use validator::Validate; | ||||
|  | ||||
| #[server] | ||||
| pub(crate) async fn create_task(new_task: NewTask) | ||||
|                                 -> Result<Task, ServerFnError<ErrorVec<TaskError>>> { | ||||
| pub(crate) async fn create_task( | ||||
|     new_task: NewTask, | ||||
| ) -> Result<Task, ServerFnError<ErrorVec<TaskError>>> { | ||||
|     use crate::schema::tasks; | ||||
|      | ||||
|  | ||||
|     // TODO: replace with model sanitization (https://github.com/matous-volf/todo-baggins/issues/13) | ||||
|     let mut new_task = new_task; | ||||
|     new_task.title = new_task.title.trim().to_owned(); | ||||
|  | ||||
|     new_task.validate() | ||||
|     new_task | ||||
|         .validate() | ||||
|         .map_err::<ErrorVec<TaskError>, _>(|errors| errors.into())?; | ||||
|  | ||||
|     let mut connection = establish_database_connection() | ||||
|         .map_err::<ErrorVec<TaskError>, _>( | ||||
|             |_| vec![TaskError::Error(Error::ServerInternal)].into() | ||||
|         )?; | ||||
|     let mut connection = | ||||
|         establish_database_connection().map_err::<ErrorVec<TaskError>, _>(|_| { | ||||
|             vec![TaskError::Error(Error::ServerInternal)].into() | ||||
|         })?; | ||||
|  | ||||
|     let new_task = diesel::insert_into(tasks::table) | ||||
|         .values(&new_task) | ||||
| @@ -58,31 +60,27 @@ pub(crate) async fn get_task(task_id: i32) -> Result<Task, ServerFnError<ErrorVe | ||||
| } | ||||
|  | ||||
| #[server] | ||||
| pub(crate) async fn get_tasks_in_category(filtered_category: Category) | ||||
|                                           -> Result<Vec<Task>, ServerFnError<ErrorVec<Error>>> { | ||||
| pub(crate) async fn get_tasks_in_category( | ||||
|     filtered_category: Category, | ||||
| ) -> Result<Vec<Task>, ServerFnError<ErrorVec<Error>>> { | ||||
|     use crate::schema::tasks::dsl::*; | ||||
|  | ||||
|     let mut connection = establish_database_connection() | ||||
|         .map_err::<ErrorVec<Error>, _>( | ||||
|             |_| vec![Error::ServerInternal].into() | ||||
|         )?; | ||||
|         .map_err::<ErrorVec<Error>, _>(|_| vec![Error::ServerInternal].into())?; | ||||
|  | ||||
|     let results = tasks | ||||
|         .select(Task::as_select()) | ||||
|         .filter(filtered_category.eq_sql_predicate()) | ||||
|         .load::<Task>(&mut connection) | ||||
|         .map_err::<ErrorVec<Error>, _>( | ||||
|             |_| vec![Error::ServerInternal].into() | ||||
|         )?; | ||||
|         .map_err::<ErrorVec<Error>, _>(|_| vec![Error::ServerInternal].into())?; | ||||
|  | ||||
|     Ok(results) | ||||
| } | ||||
|  | ||||
| #[server] | ||||
| pub(crate) async fn get_tasks_with_subtasks_in_category(filtered_category: Category) -> Result< | ||||
|     Vec<TaskWithSubtasks>, | ||||
|     ServerFnError<ErrorVec<Error>> | ||||
| > { | ||||
| pub(crate) async fn get_tasks_with_subtasks_in_category( | ||||
|     filtered_category: Category, | ||||
| ) -> Result<Vec<TaskWithSubtasks>, ServerFnError<ErrorVec<Error>>> { | ||||
|     use crate::schema::tasks; | ||||
|  | ||||
|     let mut connection = establish_database_connection() | ||||
| @@ -90,7 +88,8 @@ pub(crate) async fn get_tasks_with_subtasks_in_category(filtered_category: Categ | ||||
|  | ||||
|     let tasks_in_category = tasks::table | ||||
|         .filter(filtered_category.eq_sql_predicate()) | ||||
|         .select(Task::as_select()).load(&mut connection) | ||||
|         .select(Task::as_select()) | ||||
|         .load(&mut connection) | ||||
|         .map_err::<ErrorVec<Error>, _>(|_| vec![Error::ServerInternal].into())?; | ||||
|  | ||||
|     let subtasks = Subtask::belonging_to(&tasks_in_category) | ||||
| @@ -109,21 +108,24 @@ pub(crate) async fn get_tasks_with_subtasks_in_category(filtered_category: Categ | ||||
| } | ||||
|  | ||||
| #[server] | ||||
| pub(crate) async fn edit_task(task_id: i32, mut new_task: NewTask) | ||||
|                               -> Result<Task, ServerFnError<ErrorVec<TaskError>>> { | ||||
| pub(crate) async fn edit_task( | ||||
|     task_id: i32, | ||||
|     mut new_task: NewTask, | ||||
| ) -> Result<Task, ServerFnError<ErrorVec<TaskError>>> { | ||||
|     use crate::schema::tasks::dsl::*; | ||||
|  | ||||
|     // TODO: replace with model sanitization (https://github.com/matous-volf/todo-baggins/issues/13) | ||||
|     let mut new_task = new_task; | ||||
|     new_task.title = new_task.title.trim().to_owned(); | ||||
|      | ||||
|     new_task.validate() | ||||
|  | ||||
|     new_task | ||||
|         .validate() | ||||
|         .map_err::<ErrorVec<TaskError>, _>(|errors| errors.into())?; | ||||
|  | ||||
|     let mut connection = establish_database_connection() | ||||
|         .map_err::<ErrorVec<TaskError>, _>( | ||||
|             |_| vec![TaskError::Error(Error::ServerInternal)].into() | ||||
|         )?; | ||||
|     let mut connection = | ||||
|         establish_database_connection().map_err::<ErrorVec<TaskError>, _>(|_| { | ||||
|             vec![TaskError::Error(Error::ServerInternal)].into() | ||||
|         })?; | ||||
|  | ||||
|     let updated_task = diesel::update(tasks) | ||||
|         .filter(id.eq(task_id)) | ||||
| @@ -149,15 +151,20 @@ pub(crate) async fn complete_task(task_id: i32) -> Result<Task, ServerFnError<Er | ||||
|         reoccurrence: Some(reoccurrence), | ||||
|         date, | ||||
|         .. | ||||
|     } = &mut new_task.category { | ||||
|     } = &mut new_task.category | ||||
|     { | ||||
|         match reoccurrence.interval() { | ||||
|             ReoccurrenceInterval::Day => *date = *date + Days::new(reoccurrence.length() as u64), | ||||
|             ReoccurrenceInterval::Month | ReoccurrenceInterval::Year => { | ||||
|                 *date = *date + Months::new( | ||||
|                     reoccurrence.length() * | ||||
|                         if *(reoccurrence.interval()) == ReoccurrenceInterval::Year | ||||
|                         { 12 } else { 1 } | ||||
|                 ); | ||||
|                 *date = *date | ||||
|                     + Months::new( | ||||
|                         reoccurrence.length() | ||||
|                             * if *(reoccurrence.interval()) == ReoccurrenceInterval::Year { | ||||
|                                 12 | ||||
|                             } else { | ||||
|                                 1 | ||||
|                             }, | ||||
|                     ); | ||||
|                 *date = NaiveDate::from_ymd_opt( | ||||
|                     date.year(), | ||||
|                     date.month(), | ||||
| @@ -165,7 +172,8 @@ pub(crate) async fn complete_task(task_id: i32) -> Result<Task, ServerFnError<Er | ||||
|                         date.year(), | ||||
|                         (date.month() as u8).try_into().unwrap(), | ||||
|                     ) as u32), | ||||
|                 ).unwrap() | ||||
|                 ) | ||||
|                 .unwrap() | ||||
|             } | ||||
|         } | ||||
|         restore_subtasks_of_task(task_id).await?; | ||||
| @@ -173,7 +181,8 @@ pub(crate) async fn complete_task(task_id: i32) -> Result<Task, ServerFnError<Er | ||||
|         new_task.category = Category::Done; | ||||
|     } | ||||
|  | ||||
|     let updated_task = edit_task(task_id, new_task).await | ||||
|     let updated_task = edit_task(task_id, new_task) | ||||
|         .await | ||||
|         .map_err::<ErrorVec<Error>, _>(|_| vec![Error::ServerInternal].into())?; | ||||
|  | ||||
|     Ok(updated_task) | ||||
| @@ -182,14 +191,14 @@ pub(crate) async fn complete_task(task_id: i32) -> Result<Task, ServerFnError<Er | ||||
| // TODO: Get rid of this suppression. | ||||
| //noinspection DuplicatedCode | ||||
| #[server] | ||||
| pub(crate) async fn delete_task(task_id: i32) | ||||
|                                 -> Result<(), ServerFnError<ErrorVec<Error>>> { | ||||
| 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) | ||||
|     diesel::delete(tasks.filter(id.eq(task_id))) | ||||
|         .execute(&mut connection) | ||||
|         .map_err::<ErrorVec<Error>, _>(|error| vec![error.into()].into())?; | ||||
|  | ||||
|     Ok(()) | ||||
| @@ -197,11 +206,9 @@ pub(crate) async fn delete_task(task_id: i32) | ||||
|  | ||||
| pub(crate) async fn trigger_task_updated_at(task_id: i32) -> Result<Task, ErrorVec<Error>> { | ||||
|     use crate::schema::tasks::dsl::*; | ||||
|      | ||||
|  | ||||
|     let mut connection = establish_database_connection() | ||||
|         .map_err::<ErrorVec<Error>, _>( | ||||
|             |_| vec![Error::ServerInternal].into() | ||||
|         )?; | ||||
|         .map_err::<ErrorVec<Error>, _>(|_| vec![Error::ServerInternal].into())?; | ||||
|  | ||||
|     let updated_task = diesel::update(tasks) | ||||
|         .filter(id.eq(task_id)) | ||||
|   | ||||
		Reference in New Issue
	
	Block a user