correct typo, remove 'whatTable'

This commit is contained in:
rxf
2023-06-28 11:27:14 +02:00
parent 6857d75e9d
commit 6485ef63f6
3 changed files with 16 additions and 17 deletions
+4 -4
View File
@@ -40,7 +40,7 @@ const geigerParams = [
{name: 'sort', type: 'int', default: 1},
{name: 'last_seen', type: 'date', default: '1900-01-01T00:00:00Z'},
{name: 'datetime', type: 'date', default: null},
{name: 'mooving', type: 'bool', default: false},
{name: 'moving', type: 'bool', default: false},
]
// >>>>>>>>>>>>>>>>>>>>> DUMMIES
@@ -98,9 +98,9 @@ export const calcRange = (opts) => {
}
start = start.toUTC()
end = end.toUTC()
if(opts.avg !== undefined) {
start = start.minus({minutes: opts.avg})
}
// if(opts.avg !== undefined) {
// start = start.minus({minutes: opts.avg})
// }
ret.start = `start: ${start.toISO()}`
ret.stop = `stop: ${end.toISO()}`
return ret
+8 -2
View File
@@ -187,7 +187,7 @@ export const fetchgeigerAVGData = async (opts) => {
let sorting = {datetime: opts.sort};
let client = await connectMongo()
try {
if(opts.mooving) {
if(opts.moving) {
docs = await client.db(MONGOBASE).collection('sensors').aggregate([
{
$sort: sorting
@@ -213,7 +213,10 @@ export const fetchgeigerAVGData = async (opts) => {
}
},
{
$project: {_id:0, cpm_avg: 1, datetime:1, uSvph_avg: { $multiply: ["$cpm_avg", opts.factor]}
$project: {_id:0, cpm_avg: 1, datetime:1, uSvph_avg: { $multiply: ["$cpm_avg", opts.factor]}}
},
{
$sort: {datetime: 1}
}
]).toArray();
} else {
@@ -239,6 +242,9 @@ export const fetchgeigerAVGData = async (opts) => {
{ $addFields: { datetime: "$_id"}}, // change '_id' to 'datetime
{
$project: {_id:0, uSvph_avg: { $multiply: ["$cpm_avg", opts.factor]}, datetime: 1, cpm_avg: 1}
},
{
$sort: {datetime: 1}
}
]).toArray();
}
+2 -9
View File
@@ -80,7 +80,7 @@ export const getgeigerData = async (params, possibles, props) => {
opts.span = setoptionfromtable(opts.span, 1)
opts.daystart = setoptionfromtable(opts.daystart, false)
opts.avg = setoptionfromtable(opts.avg, 1)
opts.mooving = setoptionfromtable(opts.mooving, false)
opts.moving = setoptionfromtable(opts.moving, false)
let {start, stop} = calcRange(opts) // calc time range
opts.start = start
opts.stop = stop
@@ -95,7 +95,7 @@ export const getgeigerData = async (params, possibles, props) => {
data: opts.data,
count: erg.values.length,
avg: opts.avg,
mooving: opts.mooving
moving: opts.moving
},
values: erg.values,
}
@@ -150,10 +150,3 @@ export const getgeigerData = async (params, possibles, props) => {
return erg
}
*/
const whatTable = [
{'what':'day', 'span': 1, 'daystart': false, 'mooving': true, 'avg': 1},
{'what':'week', 'span': 7, 'daystart': false, 'mooving': true, 'avg': 180},
{'what':'month', 'span': 31, 'daystart': true, 'mooving': false, 'avg': 1440},
];