This commit is contained in:
philipp 2023-05-24 13:11:47 +02:00
parent c91db80ce5
commit 478ce329e3
2 changed files with 7 additions and 5 deletions

View File

@ -34,14 +34,13 @@ pub struct TripWithUserAndType {
impl Trip { impl Trip {
/// Cox decides to create own trip. /// Cox decides to create own trip.
pub async fn new_own(db: &SqlitePool, cox: &CoxUser, trip_details: TripDetails) { pub async fn new_own(db: &SqlitePool, cox: &CoxUser, trip_details: TripDetails) {
sqlx::query!( let _ = sqlx::query!(
"INSERT INTO trip (cox_id, trip_details_id) VALUES(?, ?)", "INSERT INTO trip (cox_id, trip_details_id) VALUES(?, ?)",
cox.id, cox.id,
trip_details.id trip_details.id
) )
.execute(db) .execute(db)
.await .await;
.unwrap(); //Okay, bc. CoxUser + TripDetails can only be created with proper DB backing
} }
pub async fn find_by_id(db: &SqlitePool, id: i64) -> Option<Self> { pub async fn find_by_id(db: &SqlitePool, id: i64) -> Option<Self> {
@ -99,7 +98,7 @@ WHERE day=?
) )
.fetch_all(db) .fetch_all(db)
.await .await
.unwrap(); //TODO: fixme .unwrap(); //Okay, as Trip can only be created with proper DB backing
let mut ret = Vec::new(); let mut ret = Vec::new();
for trip in trips { for trip in trips {

View File

@ -26,7 +26,10 @@ mod faq;
fn amount_days_to_show(is_cox: bool) -> i64 { fn amount_days_to_show(is_cox: bool) -> i64 {
if is_cox { if is_cox {
let end_of_year = NaiveDate::from_ymd_opt(Local::now().year(), 12, 31).unwrap(); let end_of_year = NaiveDate::from_ymd_opt(Local::now().year(), 12, 31).unwrap(); //Ok,
//december
//has 31
//days
end_of_year end_of_year
.signed_duration_since(Local::now().date_naive()) .signed_duration_since(Local::now().date_naive())
.num_days() .num_days()