diff --git a/backend/Cargo.lock b/backend/Cargo.lock index cd0828c..f0e6886 100644 --- a/backend/Cargo.lock +++ b/backend/Cargo.lock @@ -820,11 +820,11 @@ checksum = "4391a22b19c916e50bec4d6140f29bdda3e3bb187223fe6e3ea0b6e4d1021c04" dependencies = [ "bitflags", "byteorder", - "chrono", "diesel_derives", "itoa", "pq-sys", "r2d2", + "time 0.3.20", ] [[package]] @@ -1848,7 +1848,6 @@ dependencies = [ "actix-web", "actix-web-prom", "anyhow", - "chrono", "csv", "diesel", "diesel_migrations", @@ -1875,6 +1874,7 @@ dependencies = [ "strum_macros", "tera", "testcontainers", + "time 0.3.20", "tokio", ] diff --git a/backend/Cargo.toml b/backend/Cargo.toml index 24407e7..2c5908f 100644 --- a/backend/Cargo.toml +++ b/backend/Cargo.toml @@ -23,7 +23,7 @@ actix-session = { version = "0.7", features = ["cookie-session"]} serde = { version = "1.0.140", features = ["derive"] } serde_json = "1.0.85" tera = { version = "1", default-features = false } -diesel = { version = "2.0.0-rc.0", features = ["postgres", "r2d2", "chrono"] } +diesel = { version = "2.0.0-rc.0", features = ["postgres", "r2d2", "time"] } dotenvy = "0.15" rust-argon2 = "1.0" rand = "0.8.5" @@ -32,7 +32,7 @@ strum = "0.24.1" strum_macros = "0.24.1" futures-util = "0.3.25" csv = "1.1.6" -chrono = "0.4.23" +time = "0.3" r2d2 = "0.8.10" mockall = "0.11.4" mockall_double = "0.3.0" diff --git a/backend/src/handlers/admin.rs b/backend/src/handlers/admin.rs index 8e23900..b3eb7ab 100644 --- a/backend/src/handlers/admin.rs +++ b/backend/src/handlers/admin.rs @@ -13,13 +13,13 @@ use actix_identity::Identity; use actix_web::http::{header, StatusCode}; use actix_web::web::{self, Json}; use actix_web::{error, Error, HttpMessage, HttpRequest, HttpResponse}; -use chrono::NaiveDate; use diesel::prelude::*; use diesel::r2d2::ConnectionManager; use futures_util::stream::StreamExt as _; use r2d2::PooledConnection; use serde::{Deserialize, Serialize}; use std::collections::HashMap; +use time::{Date, Month}; #[derive(Deserialize, Serialize, Debug, PartialEq, Eq)] pub struct QueryInfo { @@ -565,12 +565,19 @@ pub async fn get_rejected_transactions( .load::(connection) .unwrap(); transaction_list.sort_by(|a, b| { - NaiveDate::parse_from_str(&b.date_of_payment, "%d.%m.%Y") - .unwrap_or_default() - .partial_cmp( - &NaiveDate::parse_from_str(&a.date_of_payment, "%d.%m.%Y").unwrap_or_default(), + Date::parse( + &b.date_of_payment, + &time::format_description::well_known::Rfc2822, + ) + .unwrap_or_else(|_| Date::from_calendar_date(1970, Month::January, 1).unwrap()) + .partial_cmp( + &Date::parse( + &a.date_of_payment, + &time::format_description::well_known::Rfc2822, ) - .unwrap() + .unwrap_or_else(|_| Date::from_calendar_date(1970, Month::January, 1).unwrap()), + ) + .unwrap() }); let mut new_transaction_list = Vec::new(); diff --git a/backend/src/models/rejected_transaction.rs b/backend/src/models/rejected_transaction.rs index a52bbc0..0528f60 100644 --- a/backend/src/models/rejected_transaction.rs +++ b/backend/src/models/rejected_transaction.rs @@ -1,10 +1,10 @@ use crate::schema::rejected_transactions; use crate::DbPool; use actix_web::web; -use chrono::NaiveDateTime; use diesel::prelude::*; use serde::Deserialize; use serde::Serialize; +use time::PrimitiveDateTime; #[derive(Insertable)] #[diesel(table_name = rejected_transactions)] @@ -31,11 +31,10 @@ pub struct RejectedTransaction { pub currency: String, pub payer_name: String, pub iban: String, - pub entry_added_at: NaiveDateTime, + pub entry_added_at: PrimitiveDateTime, } #[derive(Serialize, Deserialize, Clone)] - pub struct RejectedTransactionWithPotentialDuplicates { pub id: i32, pub runner_ids: String,