add first draft of cal

This commit is contained in:
2023-05-24 15:09:38 +02:00
parent 6b0c2059a4
commit aa2d5bc7dd
3 changed files with 50 additions and 3 deletions

View File

@ -7,12 +7,12 @@ use super::{tripdetails::TripDetails, triptype::TripType, user::User};
#[derive(Serialize, Clone, FromRow)]
pub struct PlannedEvent {
pub id: i64,
name: String,
pub name: String,
planned_amount_cox: i64,
trip_details_id: i64,
planned_starting_time: String,
pub planned_starting_time: String,
max_people: i64,
day: String,
pub day: String,
notes: Option<String>,
pub allow_guests: bool,
trip_type_id: Option<i64>,
@ -89,6 +89,18 @@ WHERE day=?",
ret
}
pub async fn all(db: &SqlitePool) -> Vec<PlannedEvent> {
sqlx::query_as!(
PlannedEvent,
"SELECT planned_event.id, planned_event.name, planned_amount_cox, trip_details_id, planned_starting_time, max_people, day, notes, allow_guests, trip_type_id
FROM planned_event
INNER JOIN trip_details ON planned_event.trip_details_id = trip_details.id",
)
.fetch_all(db)
.await
.unwrap() //TODO: fixme
}
async fn get_all_cox(&self, db: &SqlitePool) -> Vec<Registration> {
//TODO: switch to join
sqlx::query_as!(