diff --git a/src/model/logbook.rs b/src/model/logbook.rs index e63f7cc..c7bf488 100644 --- a/src/model/logbook.rs +++ b/src/model/logbook.rs @@ -85,18 +85,33 @@ impl Logbook { } pub async fn on_water(db: &SqlitePool) -> Vec { - let logs = sqlx::query_as!( - Logbook, - " - SELECT id, boat_id, shipmaster, shipmaster_only_steering, departure, arrival, destination, distance_in_km, comments, logtype - FROM logbook - WHERE arrival is null - ORDER BY departure DESC - " - ) - .fetch_all(db) - .await - .unwrap(); //TODO: fixme + let rows = sqlx::query!( + " +SELECT id, boat_id, shipmaster, shipmaster_only_steering, strftime('%Y-%m-%d %H:%M', departure) as departure, arrival, destination, distance_in_km, comments, logtype +FROM logbook +WHERE arrival is null +ORDER BY departure DESC + " +) +.fetch_all(db) +.await +.unwrap(); //TODO: fixme + + let logs: Vec = rows + .into_iter() + .map(|row| Logbook { + id: row.id, + boat_id: row.boat_id, + shipmaster: row.shipmaster, + shipmaster_only_steering: row.shipmaster_only_steering, + departure: row.departure.unwrap(), + arrival: row.arrival, + destination: row.destination, + distance_in_km: row.distance_in_km, + comments: row.comments, + logtype: row.logtype, + }) + .collect(); let mut ret = Vec::new(); for log in logs {