clean db
This commit is contained in:
@ -12,8 +12,8 @@ pub struct Logbook {
|
||||
pub shipmaster: i64,
|
||||
#[serde(default = "bool::default")]
|
||||
pub shipmaster_only_steering: bool,
|
||||
pub departure: String, //TODO: Switch to chrono::nativedatetime
|
||||
pub arrival: Option<String>, //TODO: Switch to chrono::nativedatetime
|
||||
pub departure: NaiveDateTime,
|
||||
pub arrival: Option<NaiveDateTime>,
|
||||
pub destination: Option<String>,
|
||||
pub distance_in_km: Option<i64>,
|
||||
pub comments: Option<String>,
|
||||
@ -114,7 +114,8 @@ ORDER BY departure DESC
|
||||
boat_id: row.boat_id,
|
||||
shipmaster: row.shipmaster,
|
||||
shipmaster_only_steering: row.shipmaster_only_steering,
|
||||
departure: row.departure.unwrap(),
|
||||
departure: NaiveDateTime::parse_from_str(&row.departure.unwrap(), "%Y-%m-%d %H:%M")
|
||||
.unwrap(),
|
||||
arrival: row.arrival,
|
||||
destination: row.destination,
|
||||
distance_in_km: row.distance_in_km,
|
||||
@ -125,12 +126,7 @@ ORDER BY departure DESC
|
||||
|
||||
let mut ret = Vec::new();
|
||||
for log in logs {
|
||||
let date_time_naive =
|
||||
NaiveDateTime::parse_from_str(&log.departure, "%Y-%m-%d %H:%M").unwrap();
|
||||
let date_time = Local
|
||||
.from_local_datetime(&date_time_naive)
|
||||
.single()
|
||||
.unwrap();
|
||||
let date_time = Local.from_local_datetime(&log.departure).single().unwrap();
|
||||
|
||||
ret.push(LogbookWithBoatAndRowers {
|
||||
rowers: Rower::for_log(db, &log).await,
|
||||
@ -313,12 +309,12 @@ ORDER BY departure DESC
|
||||
Ok(())
|
||||
}
|
||||
|
||||
// pub async fn delete(&self, db: &SqlitePool) {
|
||||
// sqlx::query!("DELETE FROM boat WHERE id=?", self.id)
|
||||
// .execute(db)
|
||||
// .await
|
||||
// .unwrap(); //Okay, because we can only create a User of a valid id
|
||||
// }
|
||||
pub async fn delete(&self, db: &SqlitePool) {
|
||||
sqlx::query!("DELETE FROM logbook WHERE id=?", self.id)
|
||||
.execute(db)
|
||||
.await
|
||||
.unwrap(); //Okay, because we can only create a Logbook of a valid id
|
||||
}
|
||||
}
|
||||
|
||||
#[cfg(test)]
|
||||
|
Reference in New Issue
Block a user