improvements, styling, additional infos
Some checks are pending
CI/CD Pipeline / deploy-staging (push) Blocked by required conditions
CI/CD Pipeline / deploy-main (push) Blocked by required conditions
CI/CD Pipeline / test (push) Successful in 11m13s

This commit is contained in:
2024-09-04 19:40:52 +03:00
parent 6df24f0f22
commit b40850626b
6 changed files with 192 additions and 107 deletions

View File

@ -299,6 +299,50 @@ ORDER BY departure DESC
ret
}
pub async fn year_first_logbook_entry(db: &SqlitePool, user: &User) -> Option<i32> {
let log: Option<Self> = sqlx::query_as(
&format!("
SELECT id, boat_id, shipmaster, steering_person, shipmaster_only_steering, departure, arrival, destination, distance_in_km, comments, logtype
FROM logbook
JOIN rower ON logbook.id = rower.logbook_id
WHERE arrival is not null AND rower_id = {}
ORDER BY arrival
LIMIT 1
", user.id)
)
.fetch_optional(db)
.await
.unwrap(); //TODO: fixme
if let Some(log) = log {
Some(log.arrival.unwrap().year())
} else {
None
}
}
pub async fn year_last_logbook_entry(db: &SqlitePool, user: &User) -> Option<i32> {
let log: Option<Self> = sqlx::query_as(
&format!("
SELECT id, boat_id, shipmaster, steering_person, shipmaster_only_steering, departure, arrival, destination, distance_in_km, comments, logtype
FROM logbook
JOIN rower ON logbook.id = rower.logbook_id
WHERE arrival is not null AND rower_id = {}
ORDER BY arrival DESC
LIMIT 1
", user.id)
)
.fetch_optional(db)
.await
.unwrap(); //TODO: fixme
if let Some(log) = log {
Some(log.arrival.unwrap().year())
} else {
None
}
}
pub(crate) async fn completed_wanderfahrten_with_user_over_km_in_year(
db: &SqlitePool,
user: &User,