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

This commit is contained in:
2024-12-29 19:30:35 +01:00
parent 149451cc77
commit 3646aa91c4
47 changed files with 393 additions and 296 deletions

View File

@ -1,10 +1,10 @@
use std::cmp::Ordering;
use chrono::NaiveDateTime;
use crate::internationalization::COLLATOR;
use crate::schema::projects;
use chrono::NaiveDateTime;
use diesel::prelude::*;
use serde::{Deserialize, Serialize};
use std::cmp::Ordering;
use validator::Validate;
use crate::internationalization::COLLATOR;
const TITLE_LENGTH_MIN: u64 = 1;
const TITLE_LENGTH_MAX: u64 = 255;
@ -27,11 +27,11 @@ impl Project {
pub fn title(&self) -> &str {
&self.title
}
pub fn created_at(&self) -> NaiveDateTime {
self.created_at
}
pub fn updated_at(&self) -> NaiveDateTime {
self.updated_at
}
@ -47,14 +47,21 @@ impl PartialOrd<Self> for Project {
impl Ord for Project {
fn cmp(&self, other: &Self) -> Ordering {
COLLATOR.lock().unwrap().collate(self.title(), other.title())
COLLATOR
.lock()
.unwrap()
.collate(self.title(), other.title())
}
}
#[derive(Insertable, Serialize, Deserialize, Validate, Clone, Debug)]
#[diesel(table_name = projects)]
pub struct NewProject {
#[validate(length(min = "TITLE_LENGTH_MIN", max = "TITLE_LENGTH_MAX", code = "title_length"))]
#[validate(length(
min = "TITLE_LENGTH_MIN",
max = "TITLE_LENGTH_MAX",
code = "title_length"
))]
pub title: String,
}