2023-04-04 12:19:56 +02:00
|
|
|
use chrono::NaiveDate;
|
|
|
|
use serde::Serialize;
|
|
|
|
use sqlx::SqlitePool;
|
|
|
|
|
2023-04-04 15:16:21 +02:00
|
|
|
use self::{
|
|
|
|
planned_event::{PlannedEvent, PlannedEventWithUser},
|
|
|
|
trip::{Trip, TripWithUser},
|
|
|
|
};
|
2023-04-04 12:19:56 +02:00
|
|
|
|
|
|
|
pub mod planned_event;
|
2023-04-04 15:16:21 +02:00
|
|
|
pub mod trip;
|
2023-04-04 12:19:56 +02:00
|
|
|
pub mod tripdetails;
|
2023-04-03 16:11:26 +02:00
|
|
|
pub mod user;
|
2023-04-04 15:16:21 +02:00
|
|
|
pub mod usertrip;
|
2023-04-03 17:21:34 +02:00
|
|
|
//pub mod users;
|
2023-04-04 12:19:56 +02:00
|
|
|
|
|
|
|
#[derive(Serialize)]
|
|
|
|
pub struct Day {
|
|
|
|
day: NaiveDate,
|
2023-04-04 15:16:21 +02:00
|
|
|
planned_events: Vec<PlannedEventWithUser>,
|
|
|
|
trips: Vec<TripWithUser>,
|
2023-04-04 12:19:56 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
impl Day {
|
|
|
|
pub async fn new(db: &SqlitePool, day: NaiveDate) -> Self {
|
|
|
|
Self {
|
|
|
|
day,
|
|
|
|
planned_events: PlannedEvent::get_for_day(db, day).await,
|
2023-04-04 15:16:21 +02:00
|
|
|
trips: Trip::get_for_day(db, day).await,
|
2023-04-04 12:19:56 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|