fix speeds

This commit is contained in:
Ivan 2023-08-17 12:31:56 +03:00
parent 4ef2fe7735
commit 831ea1d991
Signed by untrusted user who does not match committer: ppechenkoo
GPG Key ID: 0C191B86D9582583
2 changed files with 27 additions and 14 deletions

View File

@ -398,7 +398,12 @@ pool.query(subquery, selectedDevices, (err, result) => {
const minuteInMillis = 60000; const minuteInMillis = 60000;
const devicesData = result.rows.map((row) => ({ const devicesData = result.rows.map((row) => {
if (row.speed > 150) {
row.speed /= 100;
}
return {
serial: row.serial, serial: row.serial,
longitude: row.longitude, longitude: row.longitude,
latitude: row.latitude, latitude: row.latitude,
@ -407,7 +412,8 @@ pool.query(subquery, selectedDevices, (err, result) => {
status: Date.now() - Date.parse(row.lastkeepalive) <= minuteInMillis, status: Date.now() - Date.parse(row.lastkeepalive) <= minuteInMillis,
plate: row.plate, plate: row.plate,
group: row.group, group: row.group,
})); };
});
console.log(devicesData) console.log(devicesData)
@ -893,7 +899,7 @@ app.get('/reports/:id', async (req, res) => {
} }
templateData.Type = type; templateData.Type = type;
templateData.Speed = alarm.speed; templateData.Speed = actualSpeed;
templateData.Date = formatDate(alarm.time); templateData.Date = formatDate(alarm.time);
templateData.Serial = alarm.serial; templateData.Serial = alarm.serial;
templateData.Geo = alarm.latitude + "," + alarm.longitude; templateData.Geo = alarm.latitude + "," + alarm.longitude;
@ -910,7 +916,14 @@ app.get('/reports/:id', async (req, res) => {
templateData.NextLatitude = alarm.next_latitude; templateData.NextLatitude = alarm.next_latitude;
templateData.NextLongitude = alarm.next_longitude; templateData.NextLongitude = alarm.next_longitude;
templateData.Speeds = alarm.nearest_speeds; templateData.Speeds = alarm.nearest_speeds
templateData.Speeds = templateData.Speeds.map(speed => {
if (speed > 150) {
return speed / 100;
} else {
return speed;
}
});
console.log(templateData); console.log(templateData);

View File

@ -178,8 +178,8 @@
<video id="camera-5"></video> <video id="camera-5"></video>
<!-- <video id="camera-6"></video> <!-- <video id="camera-6"></video>
<video id="camera-7"></video> <video id="camera-7"></video>
<video id="camera-8"></video> <video id="camera-8"></video> -->
<video id="camera-9"></video> <!-- <video id="camera-9"></video>
<video id="camera-10"></video> <video id="camera-10"></video>
<video id="camera-11"></video> <video id="camera-11"></video>
<video id="camera-12"></video> <video id="camera-12"></video>