add cox_needed attribute

This commit is contained in:
2023-04-06 20:08:58 +02:00
parent 12672917bb
commit 4d49574ebb
2 changed files with 9 additions and 1 deletions

View File

@ -19,6 +19,7 @@ pub struct PlannedEvent {
pub struct PlannedEventWithUser {
#[serde(flatten)]
planned_event: PlannedEvent,
cox_needed: bool,
cox: Vec<Registration>,
rower: Vec<Registration>,
}
@ -47,9 +48,11 @@ WHERE day=?",
let mut ret = Vec::new();
for event in events {
let cox = Self::get_all_cox_for_id(db, event.id).await;
ret.push(PlannedEventWithUser {
planned_event: event.clone(),
cox: Self::get_all_cox_for_id(db, event.id).await,
cox_needed: event.planned_amount_cox > cox.len() as i64,
cox,
rower: Self::get_all_rower_for_id(db, event.id).await,
});
}