@resolveio/server-lib 4.5.4 → 4.5.6
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/methods/report-builder.js +197 -107
- package/package.json +1 -1
|
@@ -196,7 +196,7 @@ function loadReportBuilderMethods(methodManager) {
|
|
|
196
196
|
if (date_field === void 0) { date_field = ''; }
|
|
197
197
|
if (date_interval === void 0) { date_interval = ''; }
|
|
198
198
|
return new Promise(function (resolve, reject) { return __awaiter(_this, void 0, void 0, function () {
|
|
199
|
-
var _a, uniqueSelectedFieldCollections, modelCollection, queryMatchCondition, queryLookups, queryGroupUnwindCollectionPaths, queryUnwindCollectionPaths, initialProjection, queryGroups, queryGroupUnwind, initialGroup, secondInitialGroup, zipLayers, initialNonSumFilterProj, initialNonSumElemAtProj, initialNonSumValueProj, cnt, _loop_1, correctSort_1, _loop_2, i, queryProjection, queryTotals, query, i, res, err_1;
|
|
199
|
+
var _a, uniqueSelectedFieldCollections, modelCollection, queryMatchCondition, queryLookups, queryGroupUnwindCollectionPaths, queryUnwindCollectionPaths, initialProjection, queryGroups, queryGroupUnwind, initialGroup, secondInitialGroup, zipLayers, initialNonSumFilterProj, initialNonSumElemAtProj, initialNonSumValueProj, cnt, _loop_1, group, correctSort_1, _loop_2, i, queryProjection, queryTotals, query, i, res, err_1;
|
|
200
200
|
return __generator(this, function (_b) {
|
|
201
201
|
switch (_b.label) {
|
|
202
202
|
case 0:
|
|
@@ -294,49 +294,59 @@ function loadReportBuilderMethods(methodManager) {
|
|
|
294
294
|
selectedFields.filter(function (a) { return a.fieldPath.includes('$'); }).forEach(function (field) {
|
|
295
295
|
initialProjection[field.fieldPath.split('.$')[0]] = 1;
|
|
296
296
|
});
|
|
297
|
-
|
|
298
|
-
|
|
299
|
-
|
|
300
|
-
|
|
301
|
-
|
|
302
|
-
|
|
303
|
-
|
|
304
|
-
|
|
305
|
-
|
|
306
|
-
|
|
297
|
+
if (selectedFields.some(function (a) { return a.fieldPath.includes('$'); }) || groupsRow.some(function (a) { return a.field.includes('$') || a.field.includes('(Lookup)'); })) {
|
|
298
|
+
initialProjection['rb_arrays_0'] = {
|
|
299
|
+
$map: {
|
|
300
|
+
input: {
|
|
301
|
+
$zip: {
|
|
302
|
+
inputs: [
|
|
303
|
+
// '$chemicals',
|
|
304
|
+
// '$drivers',
|
|
305
|
+
// '$invoices'
|
|
306
|
+
],
|
|
307
|
+
useLongestLength: true
|
|
308
|
+
}
|
|
309
|
+
},
|
|
310
|
+
as: 'zipped',
|
|
311
|
+
in: {
|
|
312
|
+
// chemicals: {
|
|
313
|
+
// $arrayElemAt: [
|
|
314
|
+
// '$$zipped',
|
|
315
|
+
// 0
|
|
316
|
+
// ]
|
|
317
|
+
// },
|
|
318
|
+
// drivers: {
|
|
319
|
+
// $arrayElemAt: [
|
|
320
|
+
// '$$zipped',
|
|
321
|
+
// 1
|
|
322
|
+
// ]
|
|
323
|
+
// },
|
|
324
|
+
// invoices: {
|
|
325
|
+
// $arrayElemAt: [
|
|
326
|
+
// '$$zipped',
|
|
327
|
+
// 2
|
|
328
|
+
// ]
|
|
329
|
+
// }
|
|
307
330
|
}
|
|
308
|
-
},
|
|
309
|
-
as: 'zipped',
|
|
310
|
-
in: {
|
|
311
|
-
// chemicals: {
|
|
312
|
-
// $arrayElemAt: [
|
|
313
|
-
// '$$zipped',
|
|
314
|
-
// 0
|
|
315
|
-
// ]
|
|
316
|
-
// },
|
|
317
|
-
// drivers: {
|
|
318
|
-
// $arrayElemAt: [
|
|
319
|
-
// '$$zipped',
|
|
320
|
-
// 1
|
|
321
|
-
// ]
|
|
322
|
-
// },
|
|
323
|
-
// invoices: {
|
|
324
|
-
// $arrayElemAt: [
|
|
325
|
-
// '$$zipped',
|
|
326
|
-
// 2
|
|
327
|
-
// ]
|
|
328
|
-
// }
|
|
329
331
|
}
|
|
330
|
-
}
|
|
331
|
-
|
|
332
|
-
|
|
333
|
-
|
|
334
|
-
|
|
335
|
-
|
|
336
|
-
|
|
337
|
-
}
|
|
338
|
-
}
|
|
339
|
-
|
|
332
|
+
};
|
|
333
|
+
groupsRow.filter(function (a) { return a.field.includes('$'); }).forEach(function (field, index) {
|
|
334
|
+
if (!initialProjection['rb_arrays_0'].$map.input.$zip.inputs.some(function (a) { return a === '$' + field.field.split('.$')[0]; })) {
|
|
335
|
+
initialProjection['rb_arrays_0'].$map.input.$zip.inputs.push('$' + field.field.split('.$')[0]);
|
|
336
|
+
initialProjection['rb_arrays_0'].$map.in[field.field.split('.$')[0]] = {
|
|
337
|
+
$arrayElemAt: ['$$zipped', index]
|
|
338
|
+
};
|
|
339
|
+
}
|
|
340
|
+
});
|
|
341
|
+
selectedFields.filter(function (a) { return a.fieldPath.includes('$'); }).forEach(function (field, index) {
|
|
342
|
+
if (!initialProjection['rb_arrays_0'].$map.input.$zip.inputs.some(function (a) { return a === '$' + field.fieldPath.split('.$')[0]; })) {
|
|
343
|
+
initialProjection['rb_arrays_0'].$map.input.$zip.inputs.push('$' + field.fieldPath.split('.$')[0]);
|
|
344
|
+
initialProjection['rb_arrays_0'].$map.in[field.fieldPath.split('.$')[0]] = {
|
|
345
|
+
$arrayElemAt: ['$$zipped', index]
|
|
346
|
+
};
|
|
347
|
+
}
|
|
348
|
+
});
|
|
349
|
+
}
|
|
340
350
|
queryGroups = [];
|
|
341
351
|
queryGroupUnwind = [];
|
|
342
352
|
initialGroup = null;
|
|
@@ -388,8 +398,10 @@ function loadReportBuilderMethods(methodManager) {
|
|
|
388
398
|
// project next layers
|
|
389
399
|
secondInitialGroup = { _id: {} };
|
|
390
400
|
groupsRow.forEach(function (row) {
|
|
391
|
-
secondInitialGroup._id[row.id] = '$' + row.field.replace(/\.\$/g, '');
|
|
392
|
-
|
|
401
|
+
secondInitialGroup._id[row.id] = '$rb_arrays_0.' + row.field.replace(/\.\$/g, '');
|
|
402
|
+
secondInitialGroup.rb_arrays_0 = { '$push': '$rb_arrays_0' };
|
|
403
|
+
secondInitialGroup.count = { '$sum': '$count' };
|
|
404
|
+
selectedFields.filter(function (a) { return !a.fieldPath.includes('$') && a.collection_name === rootCollectionName; }).forEach(function (field) {
|
|
393
405
|
if (field.leafValueType === 'Average') {
|
|
394
406
|
secondInitialGroup[field.id] = { '$avg': '$' + (field.collection_name === rootCollectionName ? field.fieldPath.replace(/\.\$/g, '') : field.fieldPath.replace(/\.\$/g, '')) };
|
|
395
407
|
}
|
|
@@ -428,7 +440,7 @@ function loadReportBuilderMethods(methodManager) {
|
|
|
428
440
|
initialNonSumFilterProj = null;
|
|
429
441
|
initialNonSumElemAtProj = null;
|
|
430
442
|
initialNonSumValueProj = null;
|
|
431
|
-
if (selectedFields.some(function (a) { return a.fieldPath.split('.$').length === 2
|
|
443
|
+
if (selectedFields.some(function (a) { return a.fieldPath.split('.$').length === 2; })) {
|
|
432
444
|
initialNonSumFilterProj = { $addFields: {} };
|
|
433
445
|
selectedFields.filter(function (a) { return a.fieldPath.split('.$').length === 2; }).forEach(function (field) {
|
|
434
446
|
var _a;
|
|
@@ -444,9 +456,9 @@ function loadReportBuilderMethods(methodManager) {
|
|
|
444
456
|
}
|
|
445
457
|
}
|
|
446
458
|
};
|
|
447
|
-
if (filterArrayPaths.some(function (a) { return a === field.fieldPath; })) {
|
|
459
|
+
if (filterArrayPaths.some(function (a) { return a.replace(new RegExp(/\.\w+$/g), '') === field.fieldPath.replace(new RegExp(/\.\w+$/g), ''); })) {
|
|
448
460
|
var tmpOr_1 = [];
|
|
449
|
-
var filter = common_1.deepCopy(filterArrays[filterArrayPaths.
|
|
461
|
+
var filter = common_1.deepCopy(filterArrays[filterArrayPaths.findIndex(function (a) { return a.replace(new RegExp(/\.\w+$/), '') === field.fieldPath.replace(new RegExp(/\.\w+$/), ''); })]);
|
|
450
462
|
if (filter['$or']) {
|
|
451
463
|
filter['$or'].forEach(function (orVal) {
|
|
452
464
|
var _a;
|
|
@@ -491,46 +503,7 @@ function loadReportBuilderMethods(methodManager) {
|
|
|
491
503
|
}
|
|
492
504
|
cnt = 1;
|
|
493
505
|
_loop_1 = function () {
|
|
494
|
-
var group = { $group: { _id: {} } };
|
|
495
|
-
if (selectedFields.some(function (a) { return a.fieldPath.split('.$').length === cnt + 1 && (a.leafValueType === 'Average' || a.leafValueType === 'Sum'); })) {
|
|
496
|
-
groupsRow.forEach(function (row) {
|
|
497
|
-
group.$group._id[row.id] = '$_id.' + row.id;
|
|
498
|
-
});
|
|
499
|
-
group.$group['rb_arrays_' + (cnt - 1)] = { '$push': '$rb_arrays_' + (cnt - 1) };
|
|
500
|
-
selectedFields.filter(function (a) { return a.fieldPath.split('.$').length <= cnt; }).forEach(function (field) {
|
|
501
|
-
group.$group[field.id] = { $first: '$' + field.id };
|
|
502
|
-
});
|
|
503
|
-
selectedFields.filter(function (a) { return a.fieldPath.split('.$').length === cnt + 1; }).forEach(function (field) {
|
|
504
|
-
var tmpPath = field.fieldPath.split('.$.')[cnt - 1] + field.fieldPath.split('.$')[cnt];
|
|
505
|
-
if (field.leafValueType === 'Average') {
|
|
506
|
-
group.$group[field.id] = { '$avg': '$rb_arrays_' + (cnt - 1) + '.' + tmpPath };
|
|
507
|
-
}
|
|
508
|
-
else if (field.leafValueType === 'Sum') {
|
|
509
|
-
group.$group[field.id] = { '$sum': '$rb_arrays_' + (cnt - 1) + '.' + tmpPath };
|
|
510
|
-
}
|
|
511
|
-
});
|
|
512
|
-
if (fieldsTotal.length) {
|
|
513
|
-
fieldsTotal.forEach(function (total) {
|
|
514
|
-
selectedFields.filter(function (a) { return a.fieldType === 'Number' && a.fieldPath.split('.$').length === 1; }).forEach(function (field) {
|
|
515
|
-
group.$group[total.id + '_' + field.id] = { $first: '$' + field.fieldPath.replace(/\.\$/g, '') };
|
|
516
|
-
});
|
|
517
|
-
selectedFields.filter(function (a) { return a.fieldType === 'Number' && a.fieldPath.split('.$').length < cnt + 1 && a.fieldPath.split('.$').length > 1; }).forEach(function (field) {
|
|
518
|
-
var tmpPath = field.fieldPath.split('.$.')[cnt - 1] + field.fieldPath.split('.$')[cnt];
|
|
519
|
-
group.$group[total.id + '_' + field.id] = { $first: '$rb_arrays_' + (cnt - 1) + '.' + tmpPath };
|
|
520
|
-
});
|
|
521
|
-
selectedFields.filter(function (a) { return a.fieldType === 'Number' && a.fieldPath.split('.$').length === cnt + 1; }).forEach(function (field) {
|
|
522
|
-
var _a;
|
|
523
|
-
var tmpPath = field.fieldPath.split('.$.')[cnt - 1] + field.fieldPath.split('.$')[cnt];
|
|
524
|
-
group.$group[total.id + '_' + field.id] = (_a = {}, _a['$' + total.type] = '$rb_arrays_' + (cnt - 1) + '.' + tmpPath, _a);
|
|
525
|
-
});
|
|
526
|
-
});
|
|
527
|
-
}
|
|
528
|
-
zipLayers.push(group);
|
|
529
|
-
}
|
|
530
506
|
var proj = { $addFields: {} };
|
|
531
|
-
selectedFields.filter(function (a) { return a.fieldPath.split('.$').length <= cnt + 1; }).forEach(function (field) {
|
|
532
|
-
proj.$addFields[field.id] = 1;
|
|
533
|
-
});
|
|
534
507
|
if (selectedFields.some(function (a) { return a.fieldPath.split('.$').length === cnt + 2; })) {
|
|
535
508
|
proj.$addFields['rb_arrays_' + cnt] = {
|
|
536
509
|
$map: {
|
|
@@ -559,10 +532,125 @@ function loadReportBuilderMethods(methodManager) {
|
|
|
559
532
|
}
|
|
560
533
|
});
|
|
561
534
|
zipLayers.push(proj);
|
|
562
|
-
|
|
563
|
-
|
|
564
|
-
|
|
565
|
-
|
|
535
|
+
if (selectedFields.some(function (a) { return a.fieldPath.split('.$').length === cnt + 2; })) {
|
|
536
|
+
var proj_1 = { $addFields: {} };
|
|
537
|
+
selectedFields.filter(function (a) { return a.fieldPath.split('.$').length === cnt + 2; }).forEach(function (field) {
|
|
538
|
+
var _a;
|
|
539
|
+
proj_1.$addFields['rb_arrays_' + cnt + '_' + field.id] = {
|
|
540
|
+
$filter: {
|
|
541
|
+
input: '$rb_arrays_' + cnt,
|
|
542
|
+
cond: {
|
|
543
|
+
$and: [
|
|
544
|
+
{ $ne: ['$$this', null] }
|
|
545
|
+
]
|
|
546
|
+
}
|
|
547
|
+
}
|
|
548
|
+
};
|
|
549
|
+
var path = '$$this' + '.' + field.fieldPath.split('.$.')[cnt];
|
|
550
|
+
proj_1.$addFields['rb_arrays_' + cnt + '_' + field.id].$filter.cond.$and.push({ $ne: [path, null] });
|
|
551
|
+
if (filterArrayPaths.some(function (a) { return a.replace(new RegExp(/\.\w+$/), '') === field.fieldPath.replace(new RegExp(/\.\w+$/), ''); })) {
|
|
552
|
+
var tmpOr_2 = [];
|
|
553
|
+
var filter = common_1.deepCopy(filterArrays[filterArrayPaths.findIndex(function (a) { return a.replace(new RegExp(/\.\w+$/), '') === field.fieldPath.replace(new RegExp(/\.\w+$/), ''); })]);
|
|
554
|
+
if (filter['$or']) {
|
|
555
|
+
filter['$or'].forEach(function (orVal) {
|
|
556
|
+
var _a;
|
|
557
|
+
var tmpFilterPath = '';
|
|
558
|
+
for (var k = cnt; k < (Object.keys(orVal)[0]).split('.').length; k++) {
|
|
559
|
+
if (tmpFilterPath) {
|
|
560
|
+
tmpFilterPath += '.';
|
|
561
|
+
}
|
|
562
|
+
tmpFilterPath += (Object.keys(orVal)[0]).split('.')[k];
|
|
563
|
+
}
|
|
564
|
+
var filterPath = '$$this.' + tmpFilterPath;
|
|
565
|
+
tmpOr_2.push((_a = {},
|
|
566
|
+
_a[Object.keys(orVal[Object.keys(orVal)[0]])[0]] = [filterPath, orVal[Object.keys(orVal)[0]][Object.keys(orVal[Object.keys(orVal)[0]])[0]]],
|
|
567
|
+
_a));
|
|
568
|
+
});
|
|
569
|
+
}
|
|
570
|
+
else {
|
|
571
|
+
var tmpFilterPath = '';
|
|
572
|
+
for (var k = cnt; k < (Object.keys(filter)[0]).split('.').length; k++) {
|
|
573
|
+
if (tmpFilterPath) {
|
|
574
|
+
tmpFilterPath += '.';
|
|
575
|
+
}
|
|
576
|
+
tmpFilterPath += (Object.keys(filter)[0]).split('.')[k];
|
|
577
|
+
}
|
|
578
|
+
var filterPath = '$$this.' + tmpFilterPath;
|
|
579
|
+
proj_1.$addFields['rb_arrays_' + cnt + '_' + field.id].$filter.cond.$and.push((_a = {}, _a[Object.keys(filter[Object.keys(filter)[0]])[0]] = [filterPath, filter[Object.keys(filter)[0]][Object.keys(filter[Object.keys(filter)[0]])[0]]], _a));
|
|
580
|
+
}
|
|
581
|
+
if (tmpOr_2.length) {
|
|
582
|
+
proj_1.$addFields['rb_arrays_' + cnt + '_' + field.id].$filter.cond.$and.push({ $or: tmpOr_2 });
|
|
583
|
+
}
|
|
584
|
+
}
|
|
585
|
+
zipLayers.push(proj_1);
|
|
586
|
+
});
|
|
587
|
+
proj_1 = { $addFields: {} };
|
|
588
|
+
selectedFields.filter(function (a) { return a.fieldPath.split('.$').length === cnt + 2; }).forEach(function (field) {
|
|
589
|
+
proj_1.$addFields['rb_arrays_' + cnt + '_' + field.id] = '$rb_arrays_' + cnt + '_' + field.id + field.fieldPath.split('.$')[cnt];
|
|
590
|
+
});
|
|
591
|
+
zipLayers.push(proj_1);
|
|
592
|
+
proj_1 = { $addFields: {} };
|
|
593
|
+
selectedFields.filter(function (a) { return a.fieldPath.split('.$').length === cnt + 2; }).forEach(function (field) {
|
|
594
|
+
if (field.leafValueType === 'Count') {
|
|
595
|
+
proj_1.$addFields[field.id] = { '$size': '$rb_arrays_' + cnt + '_' + field.id + field.fieldPath.split('.$')[cnt + 1] };
|
|
596
|
+
}
|
|
597
|
+
else if (field.leafValueType === 'Minimum') {
|
|
598
|
+
proj_1.$addFields[field.id] = { '$min': '$rb_arrays_' + cnt + '_' + field.id + field.fieldPath.split('.$')[cnt + 1] };
|
|
599
|
+
}
|
|
600
|
+
else if (field.leafValueType === 'Maximum') {
|
|
601
|
+
proj_1.$addFields[field.id] = { '$max': '$rb_arrays_' + cnt + '_' + field.id + field.fieldPath.split('.$')[cnt + 1] };
|
|
602
|
+
}
|
|
603
|
+
else if (field.leafValueType === 'First') {
|
|
604
|
+
proj_1.$addFields[field.id] = { '$arrayElemAt': ['$rb_arrays_' + cnt + '_' + field.id + field.fieldPath.split('.$')[cnt + 1], 0] };
|
|
605
|
+
}
|
|
606
|
+
else if (field.leafValueType === 'Last') {
|
|
607
|
+
proj_1.$addFields[field.id] = { '$arrayElemAt': ['$rb_arrays_' + cnt + '_' + field.id + field.fieldPath.split('.$')[cnt + 1], -1] };
|
|
608
|
+
}
|
|
609
|
+
else if (field.leafValueType === 'Sum') {
|
|
610
|
+
proj_1.$addFields[field.id] = { '$sum': '$rb_arrays_' + cnt + '_' + field.id + field.fieldPath.split('.$')[cnt + 1] };
|
|
611
|
+
}
|
|
612
|
+
else if (field.leafValueType === 'Average') {
|
|
613
|
+
proj_1.$addFields[field.id] = { '$avg': '$rb_arrays_' + cnt + '_' + field.id + field.fieldPath.split('.$')[cnt + 1] };
|
|
614
|
+
}
|
|
615
|
+
else { //push
|
|
616
|
+
proj_1.$addFields[field.id] = '$rb_arrays_' + cnt + '_' + field.id + field.fieldPath.split('.$')[cnt + 1];
|
|
617
|
+
}
|
|
618
|
+
});
|
|
619
|
+
zipLayers.push(proj_1);
|
|
620
|
+
group = { $group: { _id: {} } };
|
|
621
|
+
if (selectedFields.some(function (a) { return a.fieldPath.split('.$').length > cnt + 1; })) {
|
|
622
|
+
groupsRow.forEach(function (row) {
|
|
623
|
+
group.$group._id[row.id] = '$_id.' + row.id;
|
|
624
|
+
});
|
|
625
|
+
group.$group['rb_arrays_' + (cnt - 1)] = { '$push': '$rb_arrays_' + (cnt - 1) };
|
|
626
|
+
selectedFields.filter(function (a) { return a.fieldPath.split('.$').length <= cnt + 2; }).forEach(function (field) {
|
|
627
|
+
group.$group[field.id] = { $first: '$' + field.id };
|
|
628
|
+
});
|
|
629
|
+
if (fieldsTotal.length) {
|
|
630
|
+
fieldsTotal.forEach(function (total) {
|
|
631
|
+
selectedFields.filter(function (a) { return a.fieldType === 'Number' && a.fieldPath.split('.$').length === 1; }).forEach(function (field) {
|
|
632
|
+
group.$group[total.id + '_' + field.id] = { $first: '$' + total.id + '_' + field.id };
|
|
633
|
+
});
|
|
634
|
+
selectedFields.filter(function (a) { return a.fieldType === 'Number' && a.fieldPath.split('.$').length < cnt + 2 && a.fieldPath.split('.$').length > 1; }).forEach(function (field) {
|
|
635
|
+
var tmpPath = field.fieldPath.split('.$.')[cnt - 1] + field.fieldPath.split('.$')[cnt];
|
|
636
|
+
group.$group[total.id + '_' + field.id] = { $first: '$rb_arrays_' + (cnt - 1) + '.' + tmpPath };
|
|
637
|
+
});
|
|
638
|
+
selectedFields.filter(function (a) { return a.fieldType === 'Number' && a.fieldPath.split('.$').length === cnt + 2; }).forEach(function (field) {
|
|
639
|
+
var _a;
|
|
640
|
+
var tmpPath = field.fieldPath.split('.$.')[cnt - 1] + field.fieldPath.split('.$')[cnt];
|
|
641
|
+
group.$group[total.id + '_' + field.id] = (_a = {}, _a['$' + total.type] = '$' + field.id, _a);
|
|
642
|
+
});
|
|
643
|
+
});
|
|
644
|
+
}
|
|
645
|
+
zipLayers.push(group);
|
|
646
|
+
}
|
|
647
|
+
}
|
|
648
|
+
if (selectedFields.some(function (a) { return a.fieldPath.split('.$').length > cnt + 2; })) {
|
|
649
|
+
zipLayers.push({ $unwind: {
|
|
650
|
+
path: '$rb_arrays_' + cnt,
|
|
651
|
+
preserveNullAndEmptyArrays: true
|
|
652
|
+
} });
|
|
653
|
+
}
|
|
566
654
|
}
|
|
567
655
|
cnt++;
|
|
568
656
|
};
|
|
@@ -772,16 +860,16 @@ function loadReportBuilderMethods(methodManager) {
|
|
|
772
860
|
});
|
|
773
861
|
}
|
|
774
862
|
if (secondInitialGroup) {
|
|
863
|
+
query.push({
|
|
864
|
+
$unwind: {
|
|
865
|
+
"path": "$rb_arrays_0",
|
|
866
|
+
"preserveNullAndEmptyArrays": true
|
|
867
|
+
}
|
|
868
|
+
});
|
|
775
869
|
query.push({
|
|
776
870
|
$group: secondInitialGroup
|
|
777
871
|
});
|
|
778
872
|
}
|
|
779
|
-
query.push({
|
|
780
|
-
$unwind: {
|
|
781
|
-
"path": "$rb_arrays_0",
|
|
782
|
-
"preserveNullAndEmptyArrays": true
|
|
783
|
-
}
|
|
784
|
-
});
|
|
785
873
|
if (initialNonSumFilterProj) {
|
|
786
874
|
query.push(initialNonSumFilterProj);
|
|
787
875
|
}
|
|
@@ -791,12 +879,14 @@ function loadReportBuilderMethods(methodManager) {
|
|
|
791
879
|
if (initialNonSumValueProj) {
|
|
792
880
|
query.push(initialNonSumValueProj);
|
|
793
881
|
}
|
|
794
|
-
|
|
795
|
-
|
|
796
|
-
|
|
797
|
-
|
|
798
|
-
|
|
799
|
-
|
|
882
|
+
if (initialGroup) {
|
|
883
|
+
query.push({
|
|
884
|
+
$unwind: {
|
|
885
|
+
"path": "$rb_arrays_0",
|
|
886
|
+
"preserveNullAndEmptyArrays": true
|
|
887
|
+
}
|
|
888
|
+
});
|
|
889
|
+
}
|
|
800
890
|
for (i = 0; i < zipLayers.length; i++) {
|
|
801
891
|
query.push(zipLayers[i]);
|
|
802
892
|
}
|
|
@@ -911,11 +1001,11 @@ function loadReportBuilderMethods(methodManager) {
|
|
|
911
1001
|
// }
|
|
912
1002
|
// }
|
|
913
1003
|
// // SORT
|
|
914
|
-
|
|
915
|
-
|
|
916
|
-
|
|
917
|
-
|
|
918
|
-
|
|
1004
|
+
if (rootOptions.sort && reportType !== 'Tabular Group') {
|
|
1005
|
+
query.push({
|
|
1006
|
+
$sort: rootOptions.sort
|
|
1007
|
+
});
|
|
1008
|
+
}
|
|
919
1009
|
// Dated Grouping
|
|
920
1010
|
// if (date_field && date_interval) {
|
|
921
1011
|
// if (date_interval === 'Daily') {
|