clean code with clippy
This commit is contained in:
@ -25,15 +25,13 @@ pub struct PlannedEventWithUser {
|
||||
|
||||
impl PlannedEvent {
|
||||
pub async fn get_for_day(db: &SqlitePool, day: NaiveDate) -> Vec<PlannedEventWithUser> {
|
||||
let day = format!("{}", day);
|
||||
let day = format!("{day}");
|
||||
let events = sqlx::query_as!(
|
||||
PlannedEvent,
|
||||
"
|
||||
SELECT planned_event.id, name, planned_amount_cox, allow_guests, trip_details_id, planned_starting_time, max_people, day, notes
|
||||
"SELECT planned_event.id, name, planned_amount_cox, allow_guests, trip_details_id, planned_starting_time, max_people, day, notes
|
||||
FROM planned_event
|
||||
INNER JOIN trip_details ON planned_event.trip_details_id = trip_details.id
|
||||
WHERE day=?
|
||||
",
|
||||
WHERE day=?",
|
||||
day
|
||||
)
|
||||
.fetch_all(db)
|
||||
@ -46,22 +44,20 @@ WHERE day=?
|
||||
planned_event: event.clone(),
|
||||
cox: Self::get_all_cox_for_id(db, event.id).await,
|
||||
rower: Self::get_all_rower_for_id(db, event.id).await,
|
||||
})
|
||||
});
|
||||
}
|
||||
ret
|
||||
}
|
||||
|
||||
pub async fn rower_can_register(db: &SqlitePool, trip_details_id: i64) -> bool {
|
||||
let amount_currently_registered = sqlx::query!(
|
||||
"
|
||||
SELECT COUNT(*) as count FROM user_trip WHERE trip_details_id = ?
|
||||
",
|
||||
"SELECT COUNT(*) as count FROM user_trip WHERE trip_details_id = ?",
|
||||
trip_details_id
|
||||
)
|
||||
.fetch_one(db)
|
||||
.await
|
||||
.unwrap(); //TODO: fixme
|
||||
let amount_currently_registered = amount_currently_registered.count as i64;
|
||||
let amount_currently_registered = i64::from(amount_currently_registered.count);
|
||||
|
||||
let amount_allowed_to_register = sqlx::query!(
|
||||
"
|
||||
@ -87,11 +83,8 @@ SELECT (SELECT name FROM user WHERE cox_id = id) as name FROM trip WHERE planned
|
||||
.fetch_all(db)
|
||||
.await
|
||||
.unwrap(); //TODO: fixme
|
||||
let mut ret = Vec::new();
|
||||
for r in res {
|
||||
ret.push(r.name);
|
||||
}
|
||||
ret
|
||||
|
||||
res.into_iter().map(|x| x.name).collect()
|
||||
}
|
||||
|
||||
async fn get_all_rower_for_id(db: &SqlitePool, id: i64) -> Vec<String> {
|
||||
@ -104,14 +97,11 @@ SELECT (SELECT name FROM user WHERE user_trip.user_id = user.id) as name FROM us
|
||||
.fetch_all(db)
|
||||
.await
|
||||
.unwrap(); //TODO: fixme
|
||||
let mut ret = Vec::new();
|
||||
for r in res {
|
||||
ret.push(r.name);
|
||||
}
|
||||
ret
|
||||
|
||||
res.into_iter().map(|x| x.name).collect()
|
||||
}
|
||||
|
||||
pub async fn new(
|
||||
pub async fn create(
|
||||
db: &SqlitePool,
|
||||
name: String,
|
||||
planned_amount_cox: i32,
|
||||
|
Reference in New Issue
Block a user