send triptype to frontend

This commit is contained in:
2023-04-28 21:19:51 +02:00
parent bd5a28b342
commit 3d5ad30904
8 changed files with 109 additions and 21 deletions

View File

@ -8,6 +8,7 @@ pub struct TripDetails {
max_people: i64,
day: String,
notes: Option<String>,
trip_type_id: Option<i64>,
}
impl TripDetails {
@ -15,7 +16,7 @@ impl TripDetails {
sqlx::query_as!(
TripDetails,
"
SELECT id, planned_starting_time, max_people, day, notes
SELECT id, planned_starting_time, max_people, day, notes, trip_type_id
FROM trip_details
WHERE id like ?
",
@ -33,13 +34,15 @@ WHERE id like ?
max_people: i32,
day: String,
notes: Option<String>,
trip_type_id: Option<i64>,
) -> i64 {
let query = sqlx::query!(
"INSERT INTO trip_details(planned_starting_time, max_people, day, notes) VALUES(?, ?, ?, ?)" ,
"INSERT INTO trip_details(planned_starting_time, max_people, day, notes, trip_type_id) VALUES(?, ?, ?, ?, ?)" ,
planned_starting_time,
max_people,
day,
notes
notes,
trip_type_id
)
.execute(db)
.await
@ -94,11 +97,11 @@ mod test {
let pool = testdb!();
assert_eq!(
TripDetails::create(&pool, "10:00".into(), 2, "1970-01-01".into(), None).await,
TripDetails::create(&pool, "10:00".into(), 2, "1970-01-01".into(), None, None).await,
3,
);
assert_eq!(
TripDetails::create(&pool, "10:00".into(), 2, "1970-01-01".into(), None).await,
TripDetails::create(&pool, "10:00".into(), 2, "1970-01-01".into(), None, None).await,
4,
);
}
@ -115,4 +118,6 @@ mod test {
fn test_true_full() {
//TODO: register user for trip_details = 1; check if is_full returns true
}
//TODO: add new tripdetails test with trip_type != None
}