show registration time for rowers
This commit is contained in:
@ -19,8 +19,15 @@ pub struct PlannedEvent {
|
||||
pub struct PlannedEventWithUser {
|
||||
#[serde(flatten)]
|
||||
planned_event: PlannedEvent,
|
||||
cox: Vec<String>,
|
||||
rower: Vec<String>,
|
||||
cox: Vec<Registration>,
|
||||
rower: Vec<Registration>,
|
||||
}
|
||||
|
||||
//TODO: move to appropriate place
|
||||
#[derive(Serialize)]
|
||||
pub struct Registration {
|
||||
pub name: String,
|
||||
pub registered_at: String,
|
||||
}
|
||||
|
||||
impl PlannedEvent {
|
||||
@ -60,9 +67,7 @@ WHERE day=?",
|
||||
let amount_currently_registered = i64::from(amount_currently_registered.count);
|
||||
|
||||
let amount_allowed_to_register = sqlx::query!(
|
||||
"
|
||||
SELECT max_people FROM trip_details WHERE id = ?
|
||||
",
|
||||
"SELECT max_people FROM trip_details WHERE id = ?",
|
||||
trip_details_id
|
||||
)
|
||||
.fetch_one(db)
|
||||
@ -73,32 +78,33 @@ WHERE day=?",
|
||||
amount_currently_registered < amount_allowed_to_register
|
||||
}
|
||||
|
||||
async fn get_all_cox_for_id(db: &SqlitePool, id: i64) -> Vec<String> {
|
||||
let res = sqlx::query!(
|
||||
async fn get_all_cox_for_id(db: &SqlitePool, id: i64) -> Vec<Registration> {
|
||||
sqlx::query_as!(
|
||||
Registration,
|
||||
"
|
||||
SELECT (SELECT name FROM user WHERE cox_id = id) as name FROM trip WHERE planned_event_id = ?
|
||||
SELECT (SELECT name FROM user WHERE cox_id = id) as name, (SELECT created_at FROM user WHERE cox_id = id) as registered_at FROM trip WHERE planned_event_id = ?
|
||||
",
|
||||
id
|
||||
)
|
||||
.fetch_all(db)
|
||||
.await
|
||||
.unwrap(); //TODO: fixme
|
||||
|
||||
res.into_iter().map(|x| x.name).collect()
|
||||
.unwrap() //TODO: fixme
|
||||
}
|
||||
|
||||
async fn get_all_rower_for_id(db: &SqlitePool, id: i64) -> Vec<String> {
|
||||
let res = sqlx::query!(
|
||||
async fn get_all_rower_for_id(db: &SqlitePool, id: i64) -> Vec<Registration> {
|
||||
sqlx::query_as!(
|
||||
Registration,
|
||||
"
|
||||
SELECT (SELECT name FROM user WHERE user_trip.user_id = user.id) as name FROM user_trip WHERE trip_details_id = (SELECT trip_details_id FROM planned_event WHERE id = ?)
|
||||
SELECT
|
||||
(SELECT name FROM user WHERE user_trip.user_id = user.id) as name,
|
||||
(SELECT created_at FROM user WHERE user_trip.user_id = user.id) as registered_at
|
||||
FROM user_trip WHERE trip_details_id = (SELECT trip_details_id FROM planned_event WHERE id = ?)
|
||||
",
|
||||
id
|
||||
)
|
||||
.fetch_all(db)
|
||||
.await
|
||||
.unwrap(); //TODO: fixme
|
||||
|
||||
res.into_iter().map(|x| x.name).collect()
|
||||
.unwrap() //TODO: fixme
|
||||
}
|
||||
|
||||
pub async fn create(
|
||||
|
Reference in New Issue
Block a user