getCityCoords added
remove 'noise_' on every value
This commit is contained in:
+22
-5
@@ -28,7 +28,7 @@ export const properties_collection = 'properties'
|
||||
|
||||
export const connectMongo = async () => {
|
||||
try {
|
||||
// logit(`Try to connect to ${MONGO_URL}`)
|
||||
// logit(`Try to connect to ${MONGO_URL}`)
|
||||
let client = await MongoClient.connect(MONGO_URL)
|
||||
// logit(`Mongodbase connected to ${MONGO_URL}`)
|
||||
return client
|
||||
@@ -154,8 +154,25 @@ export const fetchActData = async (opts) => {
|
||||
let options = { projection: {_id: 0, values: 1, datetime: 1}, sort: {datetime: 1}}
|
||||
let client = await connectMongo()
|
||||
try {
|
||||
ret.values = await client.db(MONGOBASE).collection('noise_sensors')
|
||||
.find(query, options).toArray()
|
||||
// ret.values = await client.db(MONGOBASE).collection('noise_sensors')
|
||||
// .find(query, options).toArray()
|
||||
ret.values = await client.db(MONGOBASE).collection('noise_sensors').aggregate([
|
||||
{$match: query},
|
||||
{$sort: { datetime: 1}},
|
||||
{$replaceWith:
|
||||
{
|
||||
datetime: {$dateToString: {format: '%Y-%m-%dT%H:%M:%SZ', date: '$datetime'}},
|
||||
LA_min: '$values.LA_min',
|
||||
LA_max: '$values.LA_max',
|
||||
LAeq: '$values.LAeq',
|
||||
E10tel_eq: '$values.E10tel_eq'
|
||||
}
|
||||
},
|
||||
// {$project: {
|
||||
// datetime: {$dateToString: {format: '%Y-%m-%dT%H:%M:%SZ', date: '$datetime'}},
|
||||
// _id: 0, values:1
|
||||
// }},
|
||||
]).toArray()
|
||||
}
|
||||
catch(e) {
|
||||
ret.err = e
|
||||
@@ -279,7 +296,7 @@ export const fetchNoiseAVGData = async (opts) => {
|
||||
_id: grpId,
|
||||
n_average: {$avg: "$values.E10tel_eq"}, // calculate the average
|
||||
n_sum: {$sum: "$values.E10tel_eq"}, // calculate the sum
|
||||
peakcount: {$sum: {$cond: [{$gte: ["$values.noise_LA_max", peak]}, 1, 0]}}, // count peaks
|
||||
peakcount: {$sum: {$cond: [{$gte: ["$values.LA_max", peak]}, 1, 0]}}, // count peaks
|
||||
count: {$sum: 1}, // count entries
|
||||
}
|
||||
},
|
||||
@@ -345,7 +362,7 @@ async function getAverageData(db,opt) {
|
||||
_id: grpId,
|
||||
n_average: {$avg: '$E10tel_eq'}, // calculate the average
|
||||
n_sum: {$sum: '$E10tel_eq'}, // calculate the sum
|
||||
peakcount: {$sum: {$cond: [{$gte: ["$noise_LA_max", peak]}, 1, 0]}}, // count peaks
|
||||
peakcount: {$sum: {$cond: [{$gte: ["$LA_max", peak]}, 1, 0]}}, // count peaks
|
||||
count: {$sum: 1}, // count entries
|
||||
}
|
||||
},
|
||||
|
||||
Reference in New Issue
Block a user