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(())
}
struct DbLog {
serial: u16,
time: String,
latitude: f64,
longitude: f64,
speed: u16,
height: u16,
direction: u16,
pub struct DbLog {
pub serial: u16,
pub time: String,
pub latitude: f64,
pub longitude: f64,
pub speed: u16,
pub height: u16,
pub direction: u16,
}
impl ToSql for DbLog {
@ -98,18 +98,3 @@ impl ToSql for DbLog {
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();
insert(
&conn,
&inmsg.header.serial_number,
&t.time.format("%Y-%m-%d %H:%M:%S").to_string(),
&t.latitude,
&t.longitude,
&t.speed,
&t.height,
&t.direction,
)
.unwrap();
let dblog = crate::db::DbLog {
serial: inmsg.header.serial_number,
time: t.time.format("%Y-%m-%d %H:%M:%S").to_string(),
latitude: t.latitude,
longitude: t.longitude,
speed: t.speed,
height: t.height,
direction: t.direction,
};
insert(&conn, &dblog).unwrap();
}
_ => {}
}