add notifications; fixes #127
All checks were successful
CI/CD Pipeline / test (push) Successful in 8m48s
CI/CD Pipeline / deploy-staging (push) Has been skipped
CI/CD Pipeline / deploy-main (push) Has been skipped

This commit is contained in:
2024-03-20 15:56:34 +01:00
parent 2ebfe7564a
commit be50e65846
11 changed files with 194 additions and 17 deletions

View File

@ -12,12 +12,12 @@ use super::{
#[derive(Serialize, Clone, Debug)]
pub struct Trip {
id: i64,
cox_id: i64,
pub cox_id: i64,
cox_name: String,
trip_details_id: Option<i64>,
planned_starting_time: String,
pub max_people: i64,
day: String,
pub day: String,
pub notes: Option<String>,
pub allow_guests: bool,
trip_type_id: Option<i64>,
@ -45,6 +45,23 @@ impl Trip {
.await;
}
pub async fn find_by_trip_details(db: &SqlitePool, tripdetails_id: i64) -> Option<Self> {
sqlx::query_as!(
Self,
"
SELECT trip.id, cox_id, user.name as cox_name, trip_details_id, planned_starting_time, max_people, day, trip_details.notes, allow_guests, trip_type_id, always_show, is_locked
FROM trip
INNER JOIN trip_details ON trip.trip_details_id = trip_details.id
INNER JOIN user ON trip.cox_id = user.id
WHERE trip_details.id=?
",
tripdetails_id
)
.fetch_one(db)
.await
.ok()
}
pub async fn find_by_id(db: &SqlitePool, id: i64) -> Option<Self> {
sqlx::query_as!(
Self,