Skip to content

Commit

Permalink
Replace chrono with time
Browse files Browse the repository at this point in the history
This resolves #68

Signed-off-by: Knut Borchers <knut.borchers@gmail.com>
  • Loading branch information
qutax committed May 5, 2023
1 parent 57b97f3 commit 7d237d7
Show file tree
Hide file tree
Showing 4 changed files with 19 additions and 13 deletions.
4 changes: 2 additions & 2 deletions backend/Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 2 additions & 2 deletions backend/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand All @@ -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"
Expand Down
19 changes: 13 additions & 6 deletions backend/src/handlers/admin.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down Expand Up @@ -565,12 +565,19 @@ pub async fn get_rejected_transactions(
.load::<RejectedTransaction>(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();
Expand Down
5 changes: 2 additions & 3 deletions backend/src/models/rejected_transaction.rs
Original file line number Diff line number Diff line change
@@ -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)]
Expand All @@ -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,
Expand Down

0 comments on commit 7d237d7

Please sign in to comment.