clean ui for logbook
This commit is contained in:
@ -182,6 +182,21 @@ impl Logbook {
|
||||
Ok(())
|
||||
}
|
||||
|
||||
pub async fn distances(db: &SqlitePool) -> Vec<(String, i64)>{
|
||||
let result = sqlx::query!("SELECT destination, distance_in_km FROM logbook WHERE id IN (SELECT MIN(id) FROM logbook GROUP BY destination) AND destination IS NOT NULL AND distance_in_km IS NOT NULL;")
|
||||
.fetch_all(db)
|
||||
.await
|
||||
.unwrap();
|
||||
|
||||
result.into_iter().filter_map(|r| {
|
||||
if let (Some(destination), Some(distance_in_km)) = (r.destination, r.distance_in_km) {
|
||||
Some((destination, distance_in_km))
|
||||
} else {
|
||||
None
|
||||
}
|
||||
}).collect()
|
||||
}
|
||||
|
||||
async fn remove_rowers(&self, db: &mut Transaction<'_, Sqlite>) {
|
||||
sqlx::query!("DELETE FROM rower WHERE logbook_id=?", self.id)
|
||||
.execute(db)
|
||||
|
Reference in New Issue
Block a user