fix on insert query

This commit is contained in:
Paul 2025-02-14 22:59:09 +01:00
parent d03539ce26
commit 31d16cc192
2 changed files with 7 additions and 7 deletions

View File

@ -36,7 +36,7 @@ function update(data) {
let section = parseInt(data.direction/45 + 0.5); let section = parseInt(data.direction/45 + 0.5);
section = section % 8; section = section % 8;
console.log(arrows[section]); console.log(arrows[section]);
const text = `${data.time}<br/>height: ${data.height}<br/>speed: ${speed}<br/>direction: ${arrows[section]} ${data.direction}`; const text = `time: ${data.time}<br/>latitude: ${data.latitude}<br/>longitude: ${data.longitude}<br/>height: ${data.height}<br/>speed: ${speed}<br/>direction: ${arrows[section]} ${data.direction}`;
if (!map) { if (!map) {
create_map(coords); create_map(coords);
} else { } else {

View File

@ -19,21 +19,21 @@ CREATE INDEX idx_time
const QUERY_INSERT: &'static str = " const QUERY_INSERT: &'static str = "
INSERT INTO log ( INSERT INTO log (
time, time,
serial,
latitude, latitude,
longitude, longitude,
speed, speed,
height, height,
direction direction,
serial
) )
VALUES ( VALUES (
:time, :time,
:serial,
:latitude, :latitude,
:longitude, :longitude,
:speed, :speed,
:height, :height,
:direction :direction,
:serial
)"; )";
pub fn connectdb() -> Result<Connection> { pub fn connectdb() -> Result<Connection> {
@ -69,13 +69,13 @@ pub fn prepare_insert(conn: &Connection) -> Statement {
pub fn insert(conn: &Connection, dblog: &DbLog) -> Result<()> { pub fn insert(conn: &Connection, dblog: &DbLog) -> Result<()> {
let mut stmt = prepare_insert(&conn); let mut stmt = prepare_insert(&conn);
match stmt.execute(params![ match stmt.execute(params![
dblog.serial,
dblog.time, dblog.time,
dblog.latitude, dblog.latitude,
dblog.longitude, dblog.longitude,
dblog.speed, dblog.speed,
dblog.height, dblog.height,
dblog.direction, dblog.direction,
dblog.serial,
]) { ]) {
Ok(i) => println!("{} rows were inserted", i), Ok(i) => println!("{} rows were inserted", i),
Err(err) => println!("insert failed: {}", err), Err(err) => println!("insert failed: {}", err),
@ -84,13 +84,13 @@ pub fn insert(conn: &Connection, dblog: &DbLog) -> Result<()> {
} }
pub struct DbLog { pub struct DbLog {
pub serial: u16,
pub time: String, pub time: String,
pub latitude: f64, pub latitude: f64,
pub longitude: f64, pub longitude: f64,
pub speed: u16, pub speed: u16,
pub height: u16, pub height: u16,
pub direction: u16, pub direction: u16,
pub serial: u16,
} }
impl ToSql for DbLog { impl ToSql for DbLog {