@@ -225,6 +225,7 @@ const getData = async function getData (req, res) {
225
225
* @apiName getDataMulti
226
226
* @apiParam {String} boxId Comma separated list of senseBox IDs.
227
227
* @apiParam {String} phenomenon the name of the phenomenon you want to download the data for.
228
+ * @apiParam {String} grouptag the name of the phenomenon you want to download the data for.
228
229
* @apiParam {RFC3339Date} [from-date] Beginning date of measurement data (default: 2 days ago from now)
229
230
* @apiParam {RFC3339Date} [to-date] End date of measurement data (default: now)
230
231
* @apiUse SeparatorParam
@@ -235,17 +236,22 @@ const getData = async function getData (req, res) {
235
236
* @apiParam {Boolean=true,false} [download=true] Set the `content-disposition` header to force browsers to download instead of displaying.
236
237
*/
237
238
const getDataMulti = async function getDataMulti ( req , res ) {
238
- const { boxId, bbox, exposure, delimiter, columns, fromDate, toDate, phenomenon, download, format } = req . _userParams ;
239
+ const { boxId, bbox, exposure, delimiter, columns, fromDate, toDate, phenomenon, download, format, grouptag } = req . _userParams ;
239
240
240
241
// build query
241
- const queryParams = {
242
- 'sensors.title' : phenomenon
243
- } ;
242
+ // const queryParams = {
243
+ // 'sensors.title': phenomenon
244
+ // };
245
+ const queryParams = { } ;
246
+
247
+ if ( phenomenon ) {
248
+ queryParams [ 'sensors.title' ] = phenomenon ;
249
+ }
244
250
245
251
if ( boxId && bbox ) {
246
- return Promise . reject ( new BadRequestError ( 'please specify only boxId or bbox' ) ) ;
252
+ return Promise . reject ( new BadRequestError ( 'please specify only boxId or bbox or grouptag ' ) ) ;
247
253
} else if ( ! boxId && ! bbox ) {
248
- return Promise . reject ( new BadRequestError ( 'please specify either boxId or bbox' ) ) ;
254
+ return Promise . reject ( new BadRequestError ( 'please specify either boxId or bbox or grouptag ' ) ) ;
249
255
}
250
256
251
257
if ( boxId ) {
@@ -257,6 +263,11 @@ const getDataMulti = async function getDataMulti (req, res) {
257
263
queryParams [ 'exposure' ] = { '$in' : exposure } ;
258
264
}
259
265
266
+ if ( grouptag ) {
267
+ const queryTags = grouptag . split ( ',' ) ;
268
+ queryParams [ 'grouptag' ] = { '$all' : queryTags } ;
269
+ }
270
+
260
271
try {
261
272
let stream = await Box . findMeasurementsOfBoxesStream ( {
262
273
query : queryParams ,
@@ -512,10 +523,21 @@ module.exports = {
512
523
retrieveParameters ( [
513
524
{ predef : 'sensorId' , required : true } ,
514
525
{ name : 'format' , defaultValue : 'json' , allowedValues : [ 'json' , 'csv' ] } ,
515
- { name : 'download' , defaultValue : 'false' , allowedValues : [ 'true' , 'false' ] } ,
526
+ {
527
+ name : 'download' ,
528
+ defaultValue : 'false' ,
529
+ allowedValues : [ 'true' , 'false' ]
530
+ } ,
516
531
{ predef : 'delimiter' } ,
517
532
{ name : 'outliers' , allowedValues : [ 'mark' , 'replace' ] } ,
518
- { name : 'outlierWindow' , dataType : 'Integer' , aliases : [ 'outlier-window' ] , defaultValue : 15 , min : 1 , max : 50 } ,
533
+ {
534
+ name : 'outlierWindow' ,
535
+ dataType : 'Integer' ,
536
+ aliases : [ 'outlier-window' ] ,
537
+ defaultValue : 15 ,
538
+ min : 1 ,
539
+ max : 50
540
+ } ,
519
541
{ predef : 'toDate' } ,
520
542
{ predef : 'fromDate' }
521
543
] ) ,
@@ -524,27 +546,40 @@ module.exports = {
524
546
] ,
525
547
getDataMulti : [
526
548
retrieveParameters ( [
527
- { name : 'boxId' , aliases : [ 'senseboxid' , 'senseboxids' , 'boxid' , 'boxids' ] , dataType : [ 'id' ] } ,
528
- { name : 'phenomenon' , required : true } ,
549
+ {
550
+ name : 'boxId' ,
551
+ aliases : [ 'senseboxid' , 'senseboxids' , 'boxid' , 'boxids' ] ,
552
+ dataType : [ 'id' ]
553
+ } ,
554
+ { name : 'grouptag' , required : false } ,
555
+ { name : 'phenomenon' , required : false } ,
529
556
{ predef : 'delimiter' } ,
530
- { name : 'exposure' , allowedValues : Box . BOX_VALID_EXPOSURES , dataType : [ 'String' ] } ,
557
+ {
558
+ name : 'exposure' ,
559
+ allowedValues : Box . BOX_VALID_EXPOSURES ,
560
+ dataType : [ 'String' ]
561
+ } ,
531
562
{ predef : 'columnsGetDataMulti' } ,
532
563
{ predef : 'bbox' } ,
533
564
{ predef : 'toDate' } ,
534
565
{ predef : 'fromDate' } ,
535
- { name : 'download' , defaultValue : 'true' , allowedValues : [ 'true' , 'false' ] } ,
566
+ {
567
+ name : 'download' ,
568
+ defaultValue : 'true' ,
569
+ allowedValues : [ 'true' , 'false' ]
570
+ } ,
536
571
{ name : 'format' , defaultValue : 'csv' , allowedValues : [ 'csv' , 'json' ] }
537
572
] ) ,
538
573
validateFromToTimeParams ,
539
574
getDataMulti
540
575
] ,
541
- getDataByGroupTag : [
542
- retrieveParameters ( [
543
- { name : 'grouptag' , required : true } ,
544
- { name : 'format' , defaultValue : 'json' , allowedValues : [ 'json' ] }
545
- ] ) ,
546
- getDataByGroupTag
547
- ] ,
576
+ // getDataByGroupTag: [
577
+ // retrieveParameters([
578
+ // { name: 'grouptag', required: true },
579
+ // { name: 'format', defaultValue: 'json', allowedValues: ['json'] }
580
+ // ]),
581
+ // getDataByGroupTag
582
+ // ],
548
583
getLatestMeasurements : [
549
584
retrieveParameters ( [
550
585
{ predef : 'boxId' , required : true } ,
0 commit comments