correct typo, remove 'whatTable'
This commit is contained in:
@@ -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
|
||||
|
||||
+10
-4
@@ -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,8 +213,11 @@ 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 {
|
||||
docs = await client.db(MONGOBASE).collection('sensors').aggregate([
|
||||
@@ -239,7 +242,10 @@ 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();
|
||||
}
|
||||
} catch(e) { // if there was an error
|
||||
|
||||
@@ -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},
|
||||
];
|
||||
|
||||
Reference in New Issue
Block a user