refactor: import different dependencies only in the correct target binary
Some checks failed
actionlint check / actionlint check (pull_request) Successful in 7s
checkov check / checkov check (pull_request) Successful in 53s
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 6s
GitLeaks check / GitLeaks check (pull_request) Successful in 7s
hadolint check / hadolint check (pull_request) Successful in 9s
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 7m40s
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 14s
Some checks failed
actionlint check / actionlint check (pull_request) Successful in 7s
checkov check / checkov check (pull_request) Successful in 53s
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 6s
GitLeaks check / GitLeaks check (pull_request) Successful in 7s
hadolint check / hadolint check (pull_request) Successful in 9s
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 7m40s
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 14s
This commit is contained in:
@ -7,7 +7,6 @@ use dioxus::core_macro::rsx;
|
||||
use dioxus::dioxus_core::Element;
|
||||
use dioxus::prelude::*;
|
||||
use dioxus_query::prelude::use_query_client;
|
||||
use tracing::info;
|
||||
|
||||
#[component]
|
||||
pub(crate) fn TaskList(tasks: Vec<TaskWithSubtasks>, class: Option<&'static str>) -> Element {
|
||||
|
@ -7,6 +7,7 @@ pub enum Error {
|
||||
ServerInternal,
|
||||
}
|
||||
|
||||
#[cfg(feature = "server")]
|
||||
impl From<diesel::result::Error> for Error {
|
||||
fn from(_: diesel::result::Error) -> Self {
|
||||
Self::ServerInternal
|
||||
|
@ -35,6 +35,7 @@ impl From<ValidationErrors> for ErrorVec<ProjectError> {
|
||||
}
|
||||
}
|
||||
|
||||
#[cfg(feature = "server")]
|
||||
impl From<diesel::result::Error> for ProjectError {
|
||||
fn from(_: diesel::result::Error) -> Self {
|
||||
Self::Error(Error::ServerInternal)
|
||||
|
@ -36,6 +36,7 @@ impl From<ValidationErrors> for ErrorVec<SubtaskError> {
|
||||
}
|
||||
}
|
||||
|
||||
#[cfg(feature = "server")]
|
||||
impl From<diesel::result::Error> for SubtaskError {
|
||||
fn from(diesel_error: diesel::result::Error) -> Self {
|
||||
match diesel_error {
|
||||
|
@ -36,6 +36,7 @@ impl From<ValidationErrors> for ErrorVec<TaskError> {
|
||||
}
|
||||
}
|
||||
|
||||
#[cfg(feature = "server")]
|
||||
impl From<diesel::result::Error> for TaskError {
|
||||
fn from(diesel_error: diesel::result::Error) -> Self {
|
||||
match diesel_error {
|
||||
|
@ -1,10 +1,12 @@
|
||||
mod components;
|
||||
mod errors;
|
||||
mod internationalization;
|
||||
#[cfg(feature = "server")]
|
||||
mod migrations;
|
||||
mod models;
|
||||
mod query;
|
||||
mod route;
|
||||
#[cfg(feature = "server")]
|
||||
mod schema;
|
||||
mod server;
|
||||
mod utils;
|
||||
|
@ -1,19 +1,28 @@
|
||||
#[cfg(feature = "server")]
|
||||
use crate::schema::tasks;
|
||||
use chrono::{Duration, NaiveDate, NaiveTime};
|
||||
#[cfg(feature = "server")]
|
||||
use diesel::deserialize::FromSql;
|
||||
#[cfg(feature = "server")]
|
||||
use diesel::pg::{Pg, PgValue};
|
||||
#[cfg(feature = "server")]
|
||||
use diesel::serialize::{Output, ToSql};
|
||||
#[cfg(feature = "server")]
|
||||
use diesel::sql_types::{Bool, Jsonb};
|
||||
#[cfg(feature = "server")]
|
||||
use diesel::{AsExpression, BoxableExpression, FromSqlRow, PgJsonbExpressionMethods};
|
||||
use serde::{Deserialize, Serialize};
|
||||
#[cfg(feature = "server")]
|
||||
use serde_json::json;
|
||||
use serde_with::DurationSeconds;
|
||||
use std::hash::Hash;
|
||||
#[cfg(feature = "server")]
|
||||
use std::io::Write;
|
||||
|
||||
#[serde_with::serde_as]
|
||||
#[derive(AsExpression, FromSqlRow, Serialize, Deserialize, Clone, Debug)]
|
||||
#[diesel(sql_type = Jsonb)]
|
||||
#[derive(Serialize, Deserialize, Clone, Debug)]
|
||||
#[cfg_attr(feature = "server", derive(AsExpression, FromSqlRow))]
|
||||
#[cfg_attr(feature = "server", diesel(sql_type = Jsonb))]
|
||||
pub enum Category {
|
||||
Inbox,
|
||||
SomedayMaybe,
|
||||
@ -29,6 +38,7 @@ pub enum Category {
|
||||
Trash,
|
||||
}
|
||||
|
||||
#[cfg(feature = "server")]
|
||||
impl Category {
|
||||
pub fn eq_sql_predicate(&self) -> Box<dyn BoxableExpression<tasks::table, Pg, SqlType = Bool>> {
|
||||
use crate::schema::tasks::dsl::*;
|
||||
@ -60,6 +70,7 @@ impl PartialEq for Category {
|
||||
|
||||
impl Eq for Category {}
|
||||
|
||||
#[cfg(feature = "server")]
|
||||
impl ToSql<Jsonb, Pg> for Category {
|
||||
fn to_sql<'b>(&'b self, out: &mut Output<'b, '_, Pg>) -> diesel::serialize::Result {
|
||||
let json = serde_json::to_string(self)?;
|
||||
@ -72,6 +83,7 @@ impl ToSql<Jsonb, Pg> for Category {
|
||||
}
|
||||
}
|
||||
|
||||
#[cfg(feature = "server")]
|
||||
impl FromSql<Jsonb, Pg> for Category {
|
||||
fn from_sql(bytes: PgValue) -> diesel::deserialize::Result<Self> {
|
||||
let bytes = bytes.as_bytes();
|
||||
|
@ -1,6 +1,8 @@
|
||||
use crate::internationalization::COLLATOR;
|
||||
#[cfg(feature = "server")]
|
||||
use crate::schema::projects;
|
||||
use chrono::NaiveDateTime;
|
||||
#[cfg(feature = "server")]
|
||||
use diesel::prelude::*;
|
||||
use serde::{Deserialize, Serialize};
|
||||
use std::cmp::Ordering;
|
||||
@ -9,9 +11,12 @@ use validator::Validate;
|
||||
const TITLE_LENGTH_MIN: u64 = 1;
|
||||
const TITLE_LENGTH_MAX: u64 = 255;
|
||||
|
||||
#[derive(Queryable, Selectable, Identifiable, Serialize, Deserialize, PartialEq, Clone, Debug)]
|
||||
#[diesel(table_name = crate::schema::projects)]
|
||||
#[diesel(check_for_backend(diesel::pg::Pg))]
|
||||
#[derive(Serialize, Deserialize, PartialEq, Clone, Debug)]
|
||||
#[cfg_attr(feature = "server", derive(Queryable, Selectable, Identifiable))]
|
||||
#[cfg_attr(
|
||||
feature = "server",
|
||||
diesel(table_name = crate::schema::projects, check_for_backend(diesel::pg::Pg))
|
||||
)]
|
||||
pub struct Project {
|
||||
id: i32,
|
||||
title: String,
|
||||
@ -19,6 +24,7 @@ pub struct Project {
|
||||
updated_at: NaiveDateTime,
|
||||
}
|
||||
|
||||
#[allow(dead_code)]
|
||||
impl Project {
|
||||
pub fn id(&self) -> i32 {
|
||||
self.id
|
||||
@ -54,8 +60,9 @@ impl Ord for Project {
|
||||
}
|
||||
}
|
||||
|
||||
#[derive(Insertable, Serialize, Deserialize, Validate, Clone, Debug)]
|
||||
#[diesel(table_name = projects)]
|
||||
#[derive(Serialize, Deserialize, Validate, Clone, Debug)]
|
||||
#[cfg_attr(feature = "server", derive(Insertable))]
|
||||
#[cfg_attr(feature = "server", diesel(table_name = projects))]
|
||||
pub struct NewProject {
|
||||
#[validate(length(
|
||||
min = "TITLE_LENGTH_MIN",
|
||||
|
@ -1,6 +1,9 @@
|
||||
#[cfg(feature = "server")]
|
||||
use crate::models::task::Task;
|
||||
#[cfg(feature = "server")]
|
||||
use crate::schema::subtasks;
|
||||
use chrono::NaiveDateTime;
|
||||
#[cfg(feature = "server")]
|
||||
use diesel::prelude::*;
|
||||
use serde::{Deserialize, Serialize};
|
||||
use std::cmp::Ordering;
|
||||
@ -9,20 +12,19 @@ use validator::Validate;
|
||||
const TITLE_LENGTH_MIN: u64 = 1;
|
||||
const TITLE_LENGTH_MAX: u64 = 255;
|
||||
|
||||
#[derive(
|
||||
Queryable,
|
||||
Selectable,
|
||||
Identifiable,
|
||||
Associations,
|
||||
Serialize,
|
||||
Deserialize,
|
||||
PartialEq,
|
||||
Clone,
|
||||
Debug,
|
||||
#[derive(Serialize, Deserialize, PartialEq, Clone, Debug)]
|
||||
#[cfg_attr(
|
||||
feature = "server",
|
||||
derive(Queryable, Selectable, Identifiable, Associations)
|
||||
)]
|
||||
#[cfg_attr(
|
||||
feature = "server",
|
||||
diesel(
|
||||
table_name = subtasks,
|
||||
belongs_to(Task, foreign_key = task_id),
|
||||
check_for_backend(diesel::pg::Pg)
|
||||
)
|
||||
)]
|
||||
#[diesel(belongs_to(Task, foreign_key = task_id))]
|
||||
#[diesel(table_name = subtasks)]
|
||||
#[diesel(check_for_backend(diesel::pg::Pg))]
|
||||
pub struct Subtask {
|
||||
id: i32,
|
||||
task_id: i32,
|
||||
@ -74,8 +76,9 @@ impl Ord for Subtask {
|
||||
}
|
||||
}
|
||||
|
||||
#[derive(Insertable, Serialize, Deserialize, Validate, Clone, Debug)]
|
||||
#[diesel(table_name = subtasks)]
|
||||
#[derive(Serialize, Deserialize, Validate, Clone, Debug)]
|
||||
#[cfg_attr(feature = "server", derive(Insertable))]
|
||||
#[cfg_attr(feature = "server", diesel(table_name = subtasks))]
|
||||
pub struct NewSubtask {
|
||||
pub task_id: i32,
|
||||
#[validate(length(
|
||||
|
@ -1,8 +1,10 @@
|
||||
use crate::models::category::Category;
|
||||
use crate::models::subtask::Subtask;
|
||||
#[cfg(feature = "server")]
|
||||
use crate::schema::tasks;
|
||||
use crate::utils::reverse_ord_option::ReverseOrdOption;
|
||||
use chrono::NaiveDateTime;
|
||||
#[cfg(feature = "server")]
|
||||
use diesel::prelude::*;
|
||||
use serde::{Deserialize, Serialize};
|
||||
use std::cmp::Ordering;
|
||||
@ -11,9 +13,9 @@ use validator::Validate;
|
||||
const TITLE_LENGTH_MIN: u64 = 1;
|
||||
const TITLE_LENGTH_MAX: u64 = 255;
|
||||
|
||||
#[derive(Queryable, Selectable, Identifiable, Serialize, Deserialize, PartialEq, Clone, Debug)]
|
||||
#[diesel(table_name = tasks)]
|
||||
#[diesel(check_for_backend(diesel::pg::Pg))]
|
||||
#[derive(Serialize, Deserialize, PartialEq, Clone, Debug)]
|
||||
#[cfg_attr(feature = "server", derive(Queryable, Selectable, Identifiable))]
|
||||
#[cfg_attr(feature = "server", diesel(table_name = tasks, check_for_backend(diesel::pg::Pg)))]
|
||||
pub struct Task {
|
||||
id: i32,
|
||||
title: String,
|
||||
@ -138,8 +140,9 @@ impl Ord for TaskWithSubtasks {
|
||||
}
|
||||
}
|
||||
|
||||
#[derive(Insertable, Serialize, Deserialize, Validate, Clone, Debug)]
|
||||
#[diesel(table_name = tasks)]
|
||||
#[derive(Serialize, Deserialize, Validate, Clone, Debug)]
|
||||
#[cfg_attr(feature = "server", derive(Insertable))]
|
||||
#[cfg_attr(feature = "server", diesel(table_name = tasks))]
|
||||
pub struct NewTask {
|
||||
#[validate(length(
|
||||
min = "TITLE_LENGTH_MIN",
|
||||
|
@ -9,6 +9,7 @@ pub(crate) mod projects;
|
||||
pub(crate) mod subtasks;
|
||||
pub(crate) mod tasks;
|
||||
|
||||
#[allow(dead_code)]
|
||||
#[derive(PartialEq, Debug)]
|
||||
pub(crate) enum QueryValue {
|
||||
Projects(Vec<Project>),
|
||||
@ -17,6 +18,7 @@ pub(crate) enum QueryValue {
|
||||
Subtasks(Vec<Subtask>),
|
||||
}
|
||||
|
||||
#[allow(dead_code)]
|
||||
#[derive(Debug)]
|
||||
pub(crate) enum QueryErrors {
|
||||
Error(ErrorVec<Error>),
|
||||
|
@ -4,6 +4,7 @@ use crate::server::tasks::{get_tasks_in_category, get_tasks_with_subtasks_in_cat
|
||||
use dioxus::prelude::ServerFnError;
|
||||
use dioxus_query::prelude::{use_get_query, QueryResult, UseQuery};
|
||||
|
||||
#[allow(dead_code)]
|
||||
pub(crate) fn use_tasks_in_category_query(
|
||||
category: Category,
|
||||
) -> UseQuery<QueryValue, QueryErrors, QueryKey> {
|
||||
|
@ -1,5 +1,6 @@
|
||||
use dioxus::prelude::ServerFnError;
|
||||
use dioxus::prelude::*;
|
||||
#[cfg(feature = "server")]
|
||||
use dotenvy::dotenv;
|
||||
use std::env;
|
||||
use unic_langid_impl::LanguageIdentifier;
|
||||
|
@ -1,3 +1,4 @@
|
||||
#[cfg(feature = "server")]
|
||||
pub(crate) mod database_connection;
|
||||
pub(crate) mod internationalization;
|
||||
pub(crate) mod projects;
|
||||
|
@ -2,9 +2,12 @@ use crate::errors::error::Error;
|
||||
use crate::errors::error_vec::ErrorVec;
|
||||
use crate::errors::project_error::ProjectError;
|
||||
use crate::models::project::{NewProject, Project};
|
||||
#[cfg(feature = "server")]
|
||||
use crate::server::database_connection::establish_database_connection;
|
||||
#[cfg(feature = "server")]
|
||||
use diesel::{ExpressionMethods, QueryDsl, RunQueryDsl, SelectableHelper};
|
||||
use dioxus::prelude::*;
|
||||
#[cfg(feature = "server")]
|
||||
use validator::Validate;
|
||||
|
||||
#[server]
|
||||
|
@ -2,10 +2,14 @@ use crate::errors::error::Error;
|
||||
use crate::errors::error_vec::ErrorVec;
|
||||
use crate::errors::subtask_error::SubtaskError;
|
||||
use crate::models::subtask::{NewSubtask, Subtask};
|
||||
#[cfg(feature = "server")]
|
||||
use crate::server::database_connection::establish_database_connection;
|
||||
#[cfg(feature = "server")]
|
||||
use crate::server::tasks::trigger_task_updated_at;
|
||||
#[cfg(feature = "server")]
|
||||
use diesel::{ExpressionMethods, QueryDsl, RunQueryDsl, SelectableHelper};
|
||||
use dioxus::prelude::*;
|
||||
#[cfg(feature = "server")]
|
||||
use validator::Validate;
|
||||
|
||||
#[server]
|
||||
|
@ -1,16 +1,26 @@
|
||||
use crate::errors::error::Error;
|
||||
use crate::errors::error_vec::ErrorVec;
|
||||
use crate::errors::task_error::TaskError;
|
||||
use crate::models::category::{Category, ReoccurrenceInterval};
|
||||
use crate::models::category::Category;
|
||||
#[cfg(feature = "server")]
|
||||
use crate::models::category::ReoccurrenceInterval;
|
||||
#[cfg(feature = "server")]
|
||||
use crate::models::subtask::Subtask;
|
||||
use crate::models::task::{NewTask, Task, TaskWithSubtasks};
|
||||
#[cfg(feature = "server")]
|
||||
use crate::server::database_connection::establish_database_connection;
|
||||
#[cfg(feature = "server")]
|
||||
use crate::server::subtasks::restore_subtasks_of_task;
|
||||
#[cfg(feature = "server")]
|
||||
use chrono::{Datelike, Days, Local, Months, NaiveDate};
|
||||
#[cfg(feature = "server")]
|
||||
use diesel::prelude::*;
|
||||
#[cfg(feature = "server")]
|
||||
use diesel::{ExpressionMethods, OptionalExtension, QueryDsl, RunQueryDsl, SelectableHelper};
|
||||
use dioxus::prelude::*;
|
||||
#[cfg(feature = "server")]
|
||||
use time::util::days_in_year_month;
|
||||
#[cfg(feature = "server")]
|
||||
use validator::Validate;
|
||||
|
||||
#[server]
|
||||
@ -204,6 +214,7 @@ pub(crate) async fn delete_task(task_id: i32) -> Result<(), ServerFnError<ErrorV
|
||||
Ok(())
|
||||
}
|
||||
|
||||
#[cfg(feature = "server")]
|
||||
pub(crate) async fn trigger_task_updated_at(task_id: i32) -> Result<Task, ErrorVec<Error>> {
|
||||
use crate::schema::tasks::dsl::*;
|
||||
|
||||
|
Reference in New Issue
Block a user