fix on dblog sql inserts

This commit is contained in:
Paul 2025-02-14 20:19:13 +01:00
parent 90cf89aed1
commit d03539ce26
2 changed files with 18 additions and 34 deletions

View File

@ -83,14 +83,14 @@ pub fn insert(conn: &Connection, dblog: &DbLog) -> Result<()> {
Ok(()) Ok(())
} }
struct DbLog { pub struct DbLog {
serial: u16, pub serial: u16,
time: String, pub time: String,
latitude: f64, pub latitude: f64,
longitude: f64, pub longitude: f64,
speed: u16, pub speed: u16,
height: u16, pub height: u16,
direction: u16, pub direction: u16,
} }
impl ToSql for DbLog { impl ToSql for DbLog {
@ -98,18 +98,3 @@ impl ToSql for DbLog {
Ok(self.time.to_sql().unwrap()) Ok(self.time.to_sql().unwrap())
} }
} }
impl DbLog {
fn to_params(&self) -> &[&dyn ToSql; 7] {
let res = params![
self.time,
self.serial,
self.latitude,
self.longitude,
self.speed,
self.height,
self.direction
];
res
}
}

View File

@ -323,17 +323,16 @@ impl Message {
}*/ }*/
let conn = connectdb().unwrap(); let conn = connectdb().unwrap();
insert( let dblog = crate::db::DbLog {
&conn, serial: inmsg.header.serial_number,
&inmsg.header.serial_number, time: t.time.format("%Y-%m-%d %H:%M:%S").to_string(),
&t.time.format("%Y-%m-%d %H:%M:%S").to_string(), latitude: t.latitude,
&t.latitude, longitude: t.longitude,
&t.longitude, speed: t.speed,
&t.speed, height: t.height,
&t.height, direction: t.direction,
&t.direction, };
) insert(&conn, &dblog).unwrap();
.unwrap();
} }
_ => {} _ => {}
} }