Merge pull request 'also show cox_helps_at_event in cal' (#897) from fix-cal-uid into staging
Some checks failed
CI/CD Pipeline / test (push) Failing after 12m54s
CI/CD Pipeline / deploy-staging (push) Has been skipped
CI/CD Pipeline / deploy-main (push) Has been skipped

Reviewed-on: #897
This commit is contained in:
philipp 2025-04-15 20:53:40 +02:00
commit 1c628f40ed

View File

@ -191,7 +191,8 @@ INNER JOIN trip_details ON planned_event.trip_details_id = trip_details.id",
let mut ret = Vec::new(); let mut ret = Vec::new();
let events = Self::all(db).await; let events = Self::all(db).await;
for event in events { for event in events {
if event.is_rower_registered(db, user).await { if event.is_rower_registered(db, user).await || event.is_cox_registered(db, user).await
{
ret.push(event); ret.push(event);
} }
} }
@ -215,6 +216,21 @@ INNER JOIN trip_details ON planned_event.trip_details_id = trip_details.id",
is_rower.amount > 0 is_rower.amount > 0
} }
pub async fn is_cox_registered(&self, db: &SqlitePool, user: &User) -> bool {
let is_rower = sqlx::query!(
"SELECT count(*) as amount
FROM trip
WHERE planned_event_id = ?
AND cox_id = ?",
self.id,
user.id
)
.fetch_one(db)
.await
.unwrap(); //Okay, bc planned_event can only be created with proper DB backing
is_rower.amount > 0
}
pub async fn find_by_trip_details(db: &SqlitePool, tripdetails_id: i64) -> Option<Self> { pub async fn find_by_trip_details(db: &SqlitePool, tripdetails_id: i64) -> Option<Self> {
sqlx::query_as!( sqlx::query_as!(
Self, Self,
@ -454,7 +470,6 @@ WHERE trip_details.id=?
name.push_str(&format!("{} ", triptype.name)) name.push_str(&format!("{} ", triptype.name))
} }
vevent.push(Summary::new(name)); vevent.push(Summary::new(name));
println!("{:?}", vevent);
vevent vevent
} }