Payouts finish (#470)

* Almost done

* More work on midas

* Finish payouts backend

* Update Cargo.lock

* Run fmt + prepare
This commit is contained in:
Geometrically
2022-10-30 23:34:56 -07:00
committed by GitHub
parent 6e72be54cb
commit 2ca6e67b37
31 changed files with 2267 additions and 1050 deletions

View File

@@ -73,6 +73,7 @@ where
created: result.created,
role: Role::from_string(&result.role),
badges: result.badges,
paypal_email: result.paypal_email,
}),
None => Err(AuthenticationError::InvalidCredentials),
}

View File

@@ -2,6 +2,7 @@ pub mod auth;
pub mod env;
pub mod ext;
pub mod guards;
pub mod payout_calc;
pub mod routes;
pub mod validate;
pub mod webhook;

22
src/util/payout_calc.rs Normal file
View File

@@ -0,0 +1,22 @@
use chrono::{DateTime, Datelike, NaiveDate, NaiveDateTime, NaiveTime, Utc};
pub fn get_claimable_time(
current: DateTime<Utc>,
future: bool,
) -> DateTime<Utc> {
let adder = if current.month() == 1 && !future {
(-1, 12)
} else if current.month() == 12 && future {
(1, 1)
} else {
(0, current.month())
};
DateTime::from_utc(
NaiveDateTime::new(
NaiveDate::from_ymd(current.year() + adder.0, adder.1, 16),
NaiveTime::default(),
),
Utc,
)
}

View File

@@ -89,7 +89,7 @@ pub fn validate_deps(
Ok(())
}
pub fn validate_url(value: &String) -> Result<(), validator::ValidationError> {
pub fn validate_url(value: &str) -> Result<(), validator::ValidationError> {
let url = url::Url::parse(value)
.ok()
.ok_or_else(|| validator::ValidationError::new("invalid URL"))?;