data routes done

This commit is contained in:
newtbot
2024-01-12 18:03:51 +08:00
parent 21edf3aa07
commit b3f2f4e5f6
4 changed files with 138 additions and 60 deletions

View File

@ -28,7 +28,6 @@ async function seedSensorData(seedOptions) {
}
await sensorDataModel.bulkCreate(rows)
//console.log(rows);
}
function convertDateToUTC(startDate) {
@ -85,6 +84,22 @@ function numberWithinPercent(inputNumber) {
return Math.floor(newNumber);
}
/*
function randomizeDataPoint(value, delta, maxDelta){
// https://stackoverflow.com/a/36756480
delta = Math.random() < 0.9 ? delta : maxDelta
return Math.floor(Math.random() * ((value+delta) - Math.abs(delta-value)) + Math.abs(delta-value));
}
let count = 0
let currentValue = 85
while(count <50){
count++
console.log(currentValue)
currentValue = randomizeDataPoint(currentValue, 2, 5)
}
*/
//add seed
router.post("/new", async (req, res, next) => {
@ -115,18 +130,6 @@ POST /api/v0/seed/sensordata
2) nextDataRow(lastRow, interval)
3) seedSensorData({post object from abovr})
function randomizeDataPoint(value, delta, maxDelta){
// https://stackoverflow.com/a/36756480
delta = Math.random() < 0.9 ? delta : maxDelta
return Math.floor(Math.random() * ((value+delta) - Math.abs(delta-value)) + Math.abs(delta-value));
}
let count = 0
let currentValue = 85
while(count <50){
count++
console.log(currentValue)
currentValue = randomizeDataPoint(currentValue, 2, 5)
}
*/

View File

@ -8,8 +8,6 @@ const {
getSensorDataById,
getData,
getDatabyRange,
getdataFilter,
getAverage,
} = require("../functions/apiDatabase.js");
const express = require("express");